Suggested Search

Suggested Search using Solr terms

When KonaKart is configured to use Solr (as described above), the storefront application automatically activates a suggested search widget rather than the standard search widget. As you type into the search box, a list of suggested search items appear matching the typed letters.

The KonaKart suggested search functionality uses Solr terms. For each product a number of terms are stored. The suggested search list is ordered by popularity of the term, so the more times a term has been saved, the greater chance it has of appearing in the search list. The default terms stored for each product are:

  • The category name(s) of the product. i.e. Televisions

  • The name of the product manufacturer. i.e. Sony

  • The name of the product. i.e. Vaio

  • The name of the product model. i.e. VPC-EB42FX

  • The name of the category by manufacturer. i.e. Televisions by Sony, Televisions by Philips. The added word "by" is read from the admin message catalog stored as "label.by".

  • The name of the manufacturer in a category. i.e. Sony in Televisions, Sony in Computers. The added word "in" is read from the admin message catalog stored as "label.in".

Each term is indexed with metadata containing the category, product and manufacturer ids so when a customer clicks on a term such as "Sony in Televisions" he is directed to a category view, displaying Sony products within the Televisions category. At this point he can choose another manufacturer remaining within the category and / or can apply extra filters such as screen size, LED, LCD etc. if the category has been set up with product tags to allow faceted search.

Under KonaKart/java_api_examples/src/com/konakartadmin/apiexamples you will find a Java file called MySolrMgr.java with a method that overrides the addTerm() method of the standard manager. This method allows you to decide which terms you want to index and which you want to exclude. By default, all terms are indexed. However, if for example all of your products belong to the same manufacturer or category, you may want to exclude certain terms. If you decide to change the default behavior, you must edit the konakartadmin.properties file in order to use the new manager rather than the standard manager.

konakart.admin_manager.AdminSolrMgr = com.konakartadmin.apiexamples.MySolrMgr

From version 6.3.0.0 the algorithm used to search for the search string within the term is configurable using regular expression. As can be seen from the image above, there are two configuration variables which contain the regex to add before the search string and the regex to add after the search string. The default for both configuration variables is ".*" which means that there can be any character (.) any number of times (*) before and after the search string to ensure that it finds substrings within the term. If both of these configuration variables are left empty, then the original algorithm is used where the search string has to match from the start of the term. For example if the term is "matrox g200 MMS" and the search string is "g200" the new algorithm will find the term whereas the old one wont. The old algorithm will only find the term with a search string of "mat...".

A Solr terms query returns all documents matching the search string including any documents that have been marked for deletion but not yet removed from the Solr index. In order for the standard Solr Commit command to remove the documents, the expungeDeletes attribute must be set to true. i.e. <commit expungeDeletes="true" />. Setting this attribute degrades the performance of the Commit operation and so it can be configured through a configuration variable. The default setting is "true" although if you are not using Suggested Search it's more efficient to set it to false. In order to completely rebuild the Solr index you may always issue the Optimize command. e.g. http://localhost:8983/solr/konakart/update?optimize=true .