You are here:  » Fallback on search


Fallback on search

Submitted by stevewales20 on Wed, 2013-08-07 19:50 in

I have certain items which are not being found whilst searching for them, because they are less than 3 chars.

I thought i'd added it in before, so that if under three chars it does a LIKE '%KEYWORD%' instead of the usual search. Performing that in the database seems to return the results.

Can you point out where i can add something like this?

Thanks!
Steve

Submitted by support on Thu, 2013-08-08 18:25

Hi Steve,

It's the default case that if any keyword in the query is less than 4 characters then the FULLTEXT index is not used and a basic "LIKE" query is constructed. I just checked the last search.php that I have from you, and it looks like it has been modified to reduce the limit to 3 characters, which would only work in conjunction with a change to the default MySQL configuration. Currently at line 214 I think you will find:

  if (strlen($word) <= 2 || in_array(strtolower($word),$stopwords))

...if you REPLACE that with the default:

  if (strlen($word) <= 3 || in_array(strtolower($word),$stopwords))

...then queries containing keywords of 3 characters or less will not use FULLTEXT and use the basic search method instead - that should be all it is...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Mon, 2013-08-12 10:35

Ah thanks david!

Your a star!