Solr and Magento Enterprise Edition (EE) Best Practices
Table of Contents
- Search Weight Attributes and Relevancy
- How to Best Use the Solr Example Application
- Customizing Languages
- Other Best Practices Suggestions
- Changing the Minimum Search Query (MySQL Full Text Only)
- Related Information
This article discusses some best practices discovered by Magento testing and experience. Please share your thoughts with us by commenting on this article and watch this space because we'll be adding more suggestions soon.
To improve the relevancy score of search results based on product attributes, assign a larger weight to those attributes. For more information about how to improve relevancy scores, see the following:
Solr comes packaged as a Java application that runs in a Jetty servlet engine. To make deployment even simpler, Magento EE comes packaged with a sample Solr configuration you can use and customize. It's easy to set up and get started.
Note: The sample Solr web application is not intended to be used in a production site. It's for testing and development only. It's simple to use which makes it a great way for you to learn more about Solr.
For more information, see How to Use the Solr Search Engine With Magento Enterprise Edition.
To customize localized searching for the Solr example application, edit the following files in solr-install-dir/example/solr/conf (one file per locale):
- protwords_*.txt, a list of words that are protected from stemming, which is the linguistic process of reducing a word like "catlike" to its root word "cat".
For more information about stemming, see the article on Analyzers, Tokenizers, and Token Filters on the Solr wiki.
- stopwords_*.txt, a list of words you do not want Solr to index. These typically include common words, such as the English words "the", "a", and so on. These words are referred to as stop words.
For more information about stop words, see the article on Analyzers, Tokenizers, and Token Filters on the Solr wiki, especially the discussion of solr.StopFilterFactory.
- synonyms_*.txt, a list of equivalent words (for example, "ipod", "i-pod", and "i pod").
Fore more information about synonyms, see the discussion of solr.SynonymFilterFactory on the Solr wiki.
Solr and its example application ship with these lists empty by default. Customize them as needed for your web store and language.
Other Best Practices Suggestions
Some other suggestions:
- In Solr's schema.xml, tune parameters of solr.WordDelimiterFilterFactory by modifying text_*.
For more information, see Analyzers, Tokenizers, and Token Filters on the Solr wiki.
- In the solrconfig.xml provided with Magento EE, tune parameters of magento_* request handlers (for example, <requestHandler name="magento_en" class="solr.SearchHandler">).
- To return search results from a partial SKU match, try this workaround if you're using Solr 3.6.0 or later.
By default, MySQL allows a minimum search query of four characters. However, if you're using the MySQL Fulltext search engine and the Fulltext search type, you can change the minimum number or characters to a smaller value as follows:
- Open MySQL's my.cnf in a text editor. It's located as follows:
- CentOS: /etc/my.cnf
- Ubuntu: /etc/mysql/my.conf
- Add the following line anywhere in the [mysqld] section:
ft_min_word_len=min-query-length #Example: #ft_min_word_len=3
- Save your changes to my.cnf and exit the text editor.
- Use the following command to restart MySQL:
service mysqld restart
- Use the following command to log in to MySQL as an administrator:
mysql -u admin-user-name -p
- At the mysql> prompt, enter the following commands in the order shown:
use magento-database-name; repair table catalogsearch_fulltext quick; exit
- Log in to the Admin Panel as an administrator.
- Click System > Cache Management.
- If the Status column for Page Cache indicates Invalidated, Select the check box next to Page Cache.
- From the Actions list in the upper right, click Refresh.
The following figure shows an example.
- Go to your web store and try a search for the minimum number of characters you set.