0

As the title suggest I am having an issue with setting up the plugin SearchWP to correctly work with search terms (product names) that may, or may not, contain spaces. e.g. "ABC1" or "ABC 1".

I am not entirely 100% sure how to approach this issue.

Like terms are not appropriate as it only deals with single words. "ABC 1" would be considered 2 separate words.

Fuzzy logic doesn't appear to achieve the correct results e.g. returning results for "ABC 2" "ABC 3" ABC 4".

I have tried the approach of a custom field of search synonyms for each product. Again that hasn't had the desired results either.

Any advice or guidance on this matter would be greatly appreciated.

Many thanks

5
  • SearchWP uses its own search engine, so any questsions about how it works should be directed to the plugin author/support community. It doesn't really have anything to do with WordPress development. Commented Jan 23, 2019 at 12:39
  • @JacobPeattie Apologies, I had a feeling that might be an issue. Unfortunately they appear to have closed their support forum and there isn't any presence on wordpress.org. StackExchange was my next bet.
    – noelmcg
    Commented Jan 23, 2019 at 12:45
  • Sorry, I can contact the plugin author. Cheers 👍
    – noelmcg
    Commented Jan 23, 2019 at 12:46
  • SearchWP uses a ticket system now for their support, send an email to [email protected], make sure to include your license key Commented Jan 23, 2019 at 13:38
  • @RiddleMeThis have done now, cheers.
    – noelmcg
    Commented Jan 23, 2019 at 13:42

1 Answer 1

0

Appreciate that this is in the wrong forum, but just incase this may be of some use to someone.

By using the following I can modify the search query, so that it matches the product titles. E.G if its "ABC 1" it will search for "ABC1"

function my_parse_searchwp_terms( $query, $engine ) {
   $query = preg_replace( '/(?<=abc)(\s+)(?=\d)/i', '', $query)
   return $query;
}

add_filter( 'searchwp_terms', 'my_parse_searchwp_terms', 10, 2 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.