Jump to content

PS 1.6 - Can't search special characters ( - / + )


ZikmaSolutions

Recommended Posts

  • 2 weeks later...
  • 4 months later...

First of all: the issue described here is not a bug. It's intention to give the most appropriate search results back. And special characters are difficult to handle in this context.

 

The detault behavior of the search engine is to split up search terms which special characters, like for example - / + and others. The search term AAA-BBB results then in two words to search for: AAA and BBB. The special character(s) "get lost" during this preparation step.

 

Changes are to be made in /classes/Search.php, there the defines for PREG_CLASS_SEARCH_EXCLUDE or PREG_CLASS_PUNCTUATION should be looked at. Probably the indexation would also need changes at another piece of code.

Edited by Scully (see edit history)
Link to comment
Share on other sites

Hi and Thanks for the reply.

 

I found out after a few hours searching and now I just need to figure out the correct hex value and remove the "right" one....

 

Do you have any clues about what the "-" is doing in these PREG ? As far I know they are not part of the hex values?

Link to comment
Share on other sites

Checking the code, I'd say it's in the sanitizer function. Search for this code which starts at appx. line #109, note my 3 lines which are commented out by // at the beginning.

        if ($indexation) {
            // $string = preg_replace('/[._-]+/', ' ', $string);
        } else {
            $words = explode(' ', $string);
            $processed_words = array();
            // search for aliases for each word of the query
            foreach ($words as $word) {
                $alias = new Alias(null, $word);
                if (Validate::isLoadedObject($alias)) {
                    $processed_words[] = $alias->search;
                } else {
                    $processed_words[] = $word;
                }
            }
            $string = implode(' ', $processed_words);
            $string = preg_replace('/[._]+/', '', $string);
         // $string = ltrim(preg_replace('/([^ ])-/', '$1 ', ' '.$string));
            $string = preg_replace('/[._]+/', '', $string);
         // $string = preg_replace('/[^\s]-+/', '', $string);
        }

Untested: Make a copy of your file before starting with changes. Probably a re-indexation is needed.

Edited by Scully (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...