You are here:  » Mens & Womens in search results.


Mens & Womens in search results.

Submitted by Halion on Tue, 2014-03-11 18:26 in

Hi David,

When I do a search for say Mens Slippers I'm getting lots of Womens Slippers in the search results, even the category in the associated detail page shows 'Womens' in it. Presumably that's because Mens is in the word Womens. Is there a fix for this? For example stipulating the capital M in Mens in the search critera so it only shows 'Mens Slippers'?

Thanks

Mike

Submitted by support on Wed, 2014-03-12 09:38

Hello Mike,

As every keyword in "mens slippers" is > 3 characters long this query would ordinarily trigger the full text index, but I know you've been using the script for quite a long time now and in some cases I have suggested modifications where disabling full text yeilds better results (this is often the case in very niche installations).

It does look like the query is using the basic search method which would match "womens slippers", however this can be changed to match whole words only as follows. Check your search.php for the following code around line 260:

  $where .= "search_name LIKE '%".database_safe($word)."%'";

...and REPLACE with:

  $where .= "name REGEXP '[[:<:]]".database_safe($word)."[[:>:]]'

REGEXP is quite a bit slower than LIKE but will let you match whole words only using the basic search method.

If you're still not sure, if you would like to email me your currently running version of search.php (make a back-up before trying the above mod) and include a couple of example URLs I'll check it out further for you...

Cheers,
David.
--
PriceTapestry.com