Hi David,
I've had requests from users to improve my search results. If someone searches for a specific product like: "Patagonia Babiana Swimsuit" the results are very good, but if they search for "patagonia swimsuits" the results fall apart. Is there any way to improve this? I tried turning the search description on in the advance config and that made the results worse. I was thinking there might be a way to search by brand? Any ideas?
Thanks!
Hi David,
Sorry, i didn't notice much difference. Would the include full Text set to false only include the exact term? Would setting up a brand index help this?
Here's a link to my top searches: {link saved}. As you can see I get a lot of searches for brand.
I have about 800000 products so I know it's going to be tought to get exact matches. I'm trying to educate users to type more specific queries.
Thanks,
JT
Hi David,
Don't you mean....
$config_useFullText = FALSE;
Cheers.
Keeop
Hi JT,
Exactly as Keeop mentioned (thanks, Keeop!), I meant disabling the full text index by changing line 8 of config.php to:
$config_useFullText = FALSE;
However, it may be worth adding the brand to the full text index based on your comments. Here's the steps to go about this.
Firstly, a new full text index must be created combining the brand, name and (if configured) the description. To do this, create the following makeIndex.php script, and run from the main Price Tapestry installation folder:
makeIndex.php:
<?php
require("includes/common.php");
$sql = "CREATE FULLTEXT INDEX name_brand ON `".$config_databaseTablePrefix."products` (name,brand)";
database_queryModify($sql,$result);
if ($config_searchDescription)
{
$sql = "CREATE FULLTEXT INDEX name_brand,description ON `".$config_databaseTablePrefix."products` (name,brand,description)";
database_queryModify($sql,$result);
}
print "Done.";
?>
Note - this could take a very long time against a large table. If it's feasible, it would be best to empty the products table, apply the above script, and then re-import all feeds.
With the indexes in place (and $config_useFullText left as TRUE in config.php) in your search.php look for the following code beginning at line 146:
if ($config_searchDescription)
{
$matchFields = "name,description";
}
else
{
$matchFields = "name";
}
...and REPLACE with:
if ($config_searchDescription)
{
$matchFields = "name,brand,description";
}
else
{
$matchFields = "name,brand";
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi,
Just by turning off the Full Index Text with the first solution works much better. I'll try the second one and see if that works. I'm creating the index now. do I need to remove $where .= " OR brand LIKE '%".database_safe($word)."%'";
from search.php to make the second solution work?
Thanks,
Hi Lunen,
That code should remain in place as it's required if the full text index isn't used, which is when the query contains a stopword (too common to index) or any keyword in the query is less than 4 characters...
Cheers,
David.
--
PriceTapestry.com
Hi Lunen,
Sure, you can extend search to include brand. First, make sure that the full text index is disabled in config.advanced.php by changing line 8 to:
$config_useFullText = TRUE;
Then, in search.php look for the following code at line 171:
$where .= "search_name LIKE '%".database_safe($word)."%'";
...and REPLACE with:
$where .= "search_name LIKE '%".database_safe($word)."%'";
$where .= " OR brand LIKE '%".database_safe($word)."%'";
Have a go with the above and see how you feel the results are working for your niche. It is possible to add the brand to a full text index if required...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com