Jump to content

Search doesn't work properly when entering words in Cyrillic


Recommended Posts

First, a fact: I'm really tired of discovering bugs and issues in Prestashop (no matter what version, currently I'm speaking for 1.6.0.9). That's for sure!

Here it is the current issue: Search Function Doesn't Work Properly When Entering Words In Cyrillic

 

This is the chapter for Search Preferences -> http://doc.prestashop.com/display/PS16/Search+Preferences

 

I set the weight to 0 to 8 of the 10 possible weight fields, e.g. I left only the Products name weight and Reference weight. Then I re-build the entire search index and YES, that's working.
 
When customers make a request using my shop's internal search engine, they may make mistakes in spelling. Yes, that's normal and that's why I want to display the right results to them by using the "alias" feature.
 
Well, I have already entered aliases in Cyrillic and point their right ones.

For example:

Alias: дражки за мебели, дружки за мебели, дражки за мебли, drajki za mebeli
Result: дръжки за мебели

When entering one of the alias above and hitting enter or clicking the search button nothing happened. Nothing appears in real time below the input field. The search engine just says: No results were found for your search "дружки за мебели". (or any of the four alias)

WHY? How to make this work?

 

Here it is a common theme, but the solution is not clear at all (at least to me it is not) -> https://www.prestashop.com/forums/topic/306778-solved-search-doesnt-work-for-cyrillic-language/?do=findComment&comment=1552456

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

Still not! Next month I'll give the task to my web development crew. We will find a solution because our clients need a working search engine. Not the default corrupted one.

 

I understand how frustrating this might be.  If you can not get help (there may not be solution) in community and have bug then to reach ps  developers  please open a bug report here:

http://forge.prestashop.com/secure/Dashboard.jspa

 

then if you would be so kind as to past  the bug report link back to this post for others to follow/comment/vote up that would help.

Link to comment
Share on other sites

The problem is in Search.php -> sanitize() function.

 

When you do index for search, the sanitize function will mess up Cyrillic letters, as it simply does not handle them properly. preg_replace() is used to strip out characters without regard for Cyrillic. Thus the indexation() [sic] function does not break up Cyrillic words correctly.

 

Specifically, this is the offending line:

 

$string = preg_replace('/['.PREG_CLASS_SEARCH_EXCLUDE.']+/u', ' ', $string);

 

I can understand bugs like this on young projects, but Prestashop is over 10 years old, so it's rather spectacular this wasn't discovered earlier.

Edited by helloworlder (see edit history)
  • Like 2
Link to comment
Share on other sites

×
×
  • Create New...