Jump to content

period not detected in search


keat

Recommended Posts

In /classes/catalogue.class.php, near line 1806 (CC618), THERE IS:

$words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u', '', $search_data['keywords']);

Note that there is no punctuation in the class of characters (enclosed in brackets), so the period will be removed. If this is character is important, try adding it.

The above is relevant to CubeCart's first search attempt - 'fulltext'. If there are no results, CubeCart makes a second attempt using 'rlike' - a whole-word search. The entered keyword phrase is split on spaces and commas, and the resulting array now comprises whole words whatever characters they may contain.

If still no results, CubeCart makes a third attempt using 'like' - a match of a partial word to be found in any part of the haystack. Such as 'one' being found in 'honey'.

Link to comment
Share on other sites

How odd.

I moved the period from after the 'u' to after the 's' as suggested and the search stopped finding 2.5mm, so I moved it back and it still won't find 2.5mm.

Despite clearing the cache and my browser.

Three or four attempts later, delete the file, ftp it back up, clear browser, clear cache and it works again.

Edited by keat
Link to comment
Share on other sites

  • 1 month later...

I just discovered today, that this is breaking the search.

Searching products, and i cannot scroll beyond page 1 of the results.

 

 

If I use

$words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u.', '', $search_data['keywords']);      (period after +/U)

The search breaks

If I use

$words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s.]+/u', '', $search_data['keywords']);    (period after 9\s)

The search doesn't detect the period.

Link to comment
Share on other sites

REGEX rules discuss the concept of 'character classes'. Anything inside a set of brackets is treated as things to search for. There are a few special characters that must be escaped: \s for things like spaces, tabs, new lines, etc., a 'dash allows for ranges of characters, and a couple others.

So, the period goes inside the brackets.

Note that, just inside the opening bracket, there is a circumflex (^). This means to negate the class. This statement is wanting to replace any other character not in this class with nothing, that is, remove from the search string any character that is not in the class. We do not want the period removed.

So, we need to look elsewhere why a search is not finding a product name/code/description with a period in it.

Link to comment
Share on other sites

With the period placed after the u              ( $words = preg_replace('/[^\p{Greek}a-zA-Z0-9\s]+/u.', '', $search_data['keywords']) )

I could find products containing the period.

However, when doing a normal search, i couldn't progress beyond page one of the results.

If I had 5 pages of results, choosing subsequent pages would only show the first page results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...