You are here:  » Search Problems


Search Problems

Submitted by pgabriel on Tue, 2007-01-30 17:53 in

Hello,

I have "AntiSpyware" product name. If i search for "antispyware" it shows the product. If i search for "anti" or "spyware" it doesnt show the product. What is going on?

Thanks,
Gabriel

Submitted by support on Tue, 2007-01-30 23:14

Hi Gabriel,

Price Tapestry uses 2 different methods of search, depending on the length of the query. For the best results (although with minor tradeoffs, as you have discovered), any query over 3 characters long uses performs a search using a FULL TEXT index. This type of index only works on entire words - it does not match partial words. This is the same method of search that a large search engine like Google uses.

Where the query is 3 or less characters, a standard sub-string style query is used, which in the majority of cases returns sub-standard results and is not suitable for the large product search site.

Therefore, in this example, the only word that is indexed is "antispyware", so it would have to be searched for exactly in order to return a match. However, in the overwhelming majority of cases; this method of searching provides the best results. Consider the following product name:

"Sony Vega Plasma"

You want that product to show up if someone searches for "Sony Plasma" - and with the full text index it will; and with a high relevance as well. The basic search method would not find this result.

To see where this is controlled, look for the following line in search.php (around about line 63):

if (strlen($parts[0]) > 3)
{
  // create SQL for FULL TEXT index search
}
else
{
  // create SQL for basic search
}

If you want to experiment by turning off the use of the full text index then you can change the top line as follows:

if (0)

This will force all searches to use the basic search method, and you can compare the results to the normal method.

Hope this helps explain the situation!
Cheers,
David.

Submitted by pgabriel on Wed, 2007-01-31 21:55

Thanks,
I`ve just modified this:

if (strlen($parts[0]) > 3)

into this:

if (strlen($parts[0]) > 30)

Thanks,
Gabriel

Submitted by pgabriel on Sun, 2007-02-04 12:33

David,

I have a little issue, or i dont understand what is happening when u search for more than 3 characters. I have only one product in my database, this is: "Televizor Samsung". When i search for "tel" it returns the result. When i search for "televizor" or "samsung" it returns nothing. Why is this happening. I have to mention that is the standard platform that i`ve downloaded from here with no other modifications.

Thanks,
Gabriel

Submitted by pgabriel on Sun, 2007-02-04 13:15

I`ve read this thread: http://www.pricetapestry.com/node/774 and i`ve done the modifications. It works great. Any other things i should know about this?

Thanks,
Gabriel

Submitted by support on Sun, 2007-02-04 16:24

Hello Gabriel,

This is also to do with the full text index. MySQL does not index words that appear in > 50% of the records; so if you only have 1 record then a full text index cannot be created. If you have at least 3 products you will get results.

Cheers,
David.

Submitted by support on Sun, 2007-02-04 16:27

Regarding the boolean search mods - no, if it's working fine and you're happy with the results it gives there's no reason not to use it.

For more info on the type of queries you can perform see the following page:

http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

Cheers,
David.