Knowledgebase
[TUTORIAL] How to tune the results of the Smart Search
Posted by Nick Poindexter on 04 March 2010 05:02 PM
The Smart Search assigns a weight to each searchable field on your site. You can then adjust the importance of a match in each individual section to improve the relevancy of the results on your store.

The sections are:

Title
Description
Full Description
Keywords
SKU
Variants
Extra Fields

If you site has a lot of unique highly customized data in the description field you will want to give this a higher weight. Likewise if you have a lot of redundant common information in the full description fields you can lower the relevancy of a match in this section.

To tune your search.

1. Start with a query where you aren't happy with the order of the results.

2. Add &tune=npquery to the end of the URL. For example: /_search.php?page=1&q=search+query&tune=npquery

3. At the top of the page a list of productids and their matching score will be displayed. For example:

Debug [0/0]: Array
(
[69] => 10101
[5502] => 10102
[5503] => 10086
[5504] => 10032
[5501] => 10011
[5134] => 10011
[5132] => 10009
[5133] => 10006
[7592] => 987
[5131] => 877

4. Open the /modules/Smart_Search/smart_search_config.php file and find this section of code near line 60:

$weight = array();
$weight['title'] = 5; // Title //
$weight['descr'] = 1; // Short Description //
$weight['fulldescr'] = 1; // Full Description //
$weight['keywords'] = 3;
$weight['sku'] = 1;
$weight['variants'] = 2;
$weight['extra_fields'] = 1; // Used only for the extra fields add-on //
$weight['custom_fields'] = 1; // Used only for custom fields on the xcart_products table //


A bit of trial and error will be needed, but as you adjust the weight of these fields you can then track the relevancy the Smart Search assigns to a product.

For example. If a search for "red sweater" returns too many results on your site because the word "red" is found in a lot of keywords, lower the weight of the keywords field:

$weight['keywords'] = 3;


You can also increase the weight of fields to make others less relevant. In this case if the descr field is set to 1, and this can't be lowered.

$weight['descr'] = 1;


Setting the title to a higher number will also cause matches to the descr field to appear lower in the results.

$weight['title'] = 100;



The fields can be any integer above 0. For example: 1, 900, 9999999, 80, etc.

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments: