You are here:  » Problem with search function


Problem with search function

Submitted by johan_norlund on Thu, 2006-07-13 12:29 in

Sorry for bugging you again, David, but this one is quite confusing.

Check this search query out:
http://www.electronicsstores.com/search.php?q=sony

It returns every product with "sony" in the product name field. Now, let's try another search:
http://www.electronicsstores.com/search.php?q=canon+dsc

As you can see, the search results are the exact same. Shouldn't that search term return all products with "sony dsc" in the product name field?

And finally:
http://www.electronicsstores.com/search.php?q=sony+sdfsdfsdfsdfsdf
Shouldn't this return "no search results"?

Any ideas?
Thanks!
Johan

Submitted by support on Thu, 2006-07-13 13:18

Hi Johan,

What you're seeing is a by-product of the way MySQL's "Full Text" indexing works. For performance reasons, words less than 4 characters are not indexed, hense the "dsc" of your example query is actually ignored.

Likewise with your second example, the Full Text query returns results in order of relevance, and it is not necessary for a product name to contain all the words in the query in order to be returned. This is generally considered to be a good thing, as it means your users will find related products if you don't have the exact product they were looking for.

There's some more info in this thread:
http://www.pricetapestry.com/node/316

Cheers,
David.

Submitted by johan_norlund on Thu, 2006-07-13 17:21

Oops, the second URL should of course be
http://www.electronicsstores.com/search.php?q=sony+dsc
(not that it matters)

Okay! That explains the issue. Too bad that 3-letter words are excluded. I mean, MANY product model names contain those. Is there no way to work around this, to only exclude words less than 3 characters?

...or will the search queries take a LOT more time after such a modification?

Thanks again. I still cannot believe how great your support is!
/Johan

Submitted by support on Thu, 2006-07-13 18:50

Hi Johan,

If you are running MySQL version 4.x (version checker) you can use my.cnf to configure the Full Text index to include 3-letter words. Prior to version 4, it would be necessary to recompile MySQL. After making any changes to the indexing configuration it would be necessary to re-import everything so that the index is rebuilt. There's more information on the following page:

http://dev.mysql.com/doc/refman/4.1/en/fulltext-fine-tuning.html

It might also be worth reading the discussion on this forum when we first introduced full text indexing...

http://www.pricetapestry.com/node/79

Let me know how you find performance if you decide to give it a go...!

Cheers,
David.