is available for Magento® 2
How to use the Elasticsearch extension?
Elasticsearch is a real-time distributed search and analytics engine which allows you to explore your data very quickly. It is used for full-text search, structured search, analytics, and all three in combination.
And it packages up all this functionality into a standalone server that your application can talk to via a simple RESTful API, using a web client from your favorite programming language, or even from the command line.
The Elasticsearch extension will allow you to make the link between the search and analytics engine and Magento.
You can find more information on the product here:
STEP 1: Install and run Elasticsearch server
As Elastic advises, "the easiest way to understand what Elasticsearch can do for you is to play with it".
To be able to use the Elasticsearch extension and reach the server, you first need to have a recent version of Java. You can easily install the latest version of Java from www.java.com.
Then you can install and run the Elasticsearch engine following below steps.
You can download the latest version of Elasticsearch from elastic.co/downloads/elasticsearch.
Once it is downloaded, you can extract the archive file.
Once you’ve extracted the archive file, Elasticsearch is ready to run.
To run Elasticsearch, open a console and run the following command:
If you’re running Elasticsearch on Windows, simply run:
You can easily test if the Elasticsearch engine is reached by opening a new terminal window and running the following:
You should then get:
You now have an Elasticsearch node up and running.
STEP 2: Enable the Elasticsearch method
To configure Elasticsearch in a general way, go to System > Configuration > Catalog > Catalog > Search.
Configure the general parameters
In the Catalog Search tab, you can choose Elasticsearch as the Search Engine.
When choosing Elasticsearch as the Search engine, more options should display:
- Enable Debug Mode: will display potential error messages in the frontend.
- Enable Suggestion: will display a suggestion if search engine detects a better text query ("Did you mean?" feature).
- Servers: must be written as host:port and separated by a comma.
- Verify Host: only used for https connection. Set that option to No if you don't have a valid SSL certificate.
- Server Timeout: number of seconds after a timeout occurs for every request. If you’re using indexing of file, large value is necessary.
- Index Prefix: used to prefix index names in order to avoid potential collisions.
- Number of Shards: having more shards enhances the indexing performance and allows to distribute a big index across machines.
- Number of Replicas: define the number of replicas. Note that having more replicas enhances the search performance and improves the cluster availability.
- Safe Reindex: reindex in a temporary index and switch to it once finished. Especially useful for large product catalogs.
- Query Operator: by default it is set to AND. For example, with the AND operator, the same query is translated to "digital AND camera", with the OR operator, the query "digital camera" is translated to "digital OR camera". You may have less results with the AND operator but they’ll be more relevant.
- Enable Source Storage: should we store source data in Elasticsearch or not. Keep this setting to No for better performances. Will be forced to Yes if fast autocomplete is enabled.
- Enable Fuzzy Query: enable the approximative search.
Manage your Indexes
The Elastic Search extension adds 3 more indexes that you can find in System > Index Management:
- Elasticsearch Product: Rebuild product fulltext search index
- Elasticsearch Category: Rebuild category fulltext search index
- Elasticsearch CMS Pages: Rebuild CMS pages fulltext search index
You can easily reindex data by selecting those 3 indexes and by clicking on Submit.
STEP 3: Configure your search with Elastic Search
You can now configure your search in System > Configuration > Bubble Extensions > Elasticsearch.
In the General Settings subtab, you will be able to Enable Response Header. This will enable a custom response header for debug purpose.
By default, the autocomplete will display terms suggestions for your search.
You can choose to Enable Autocomplete in order to override the default autocomplete and to display products directly.
If enabled, 2 additional options will be displayed:
- Autocomplete Limit: define the maximum number of results displayed in the autocompletion. For example 3.
- Enable Fast Autocomplete: use the fast autocomplete (with a payload during indexation).
You can also define a translation for each one of the labels that will be displayed in the autocomplete box as well as add new ones in the Autocomplete Labels field.
This option is very useful if your website is available in different languages. You can then change the scope to a store view, for example the French one, and translate each autocomplete label to the French word.
Below is what you should get with the above example:
With the Elastic Search extension, you can make your products searchable in the autocomple box. Several options exist to enhance the search.
- Enable Auto Redirect: If only 1 result matches the query, the user will be redirected to the product page automatically.
- Enable in Autocomplete: If enabled, products will be searchable in the autocomplete box.
- Image Size: define the size of the images in the autocomplete box in px. By default the value is set on 50px.
- Enable Thumbnails Generation: enable that option if you want to generate products thumbnails. They’ll be generated during indexation and increase execution time. Note that this will impact only the first indexation process since thumbnails are cached for next indexations. If that option is disabled, the uploaded images will be used without any payload at indexation time but big images may be loaded in autocomplete box.
You can Enable Category Search. If enabled, categories will then be indexed in Elasticsearch and new parameters will be displayed in the configuration.
- Enable in Search Results: if enabled, categories will also be displayed in the right column of search results page.
- Enable in Autocomplete: if enabled, categories will also be searchable in autocomplete box.
- Search Results Limit: is the limit number of results that will be displayed in the right column of search results page. Note that 0 or empty field means unlimited.
- Show Category Path: If enabled, category path will be displayed in the right column of search results page.
- Searchable Attributes: define which category attributes are searchable. For example the Description and the Name.
You can Enable CMS Search. If enabled, CMS pages will be indexed in Elasticsearch and new parameters will be displayed in the configuration.
- Enable in Search Results: If enabled, CMS pages will also be displayed in the right column of the search results page.
- Enable in Autocomplete: If enabled, CMS pages will also be searchable in the autocomplete box.
- Search Results Limit: Limit number of results displayed in the right column of the search results page. Note that “0” or empty means unlimited.
- Searchable Attributes: Define which attributes are searchable.
- Excluded Pages: Selected CMS pages will be excluded from search.
STEP 4: Manage the weight of the attributes and product in order to refine the search results
The Elastic Search extension allows you to easily boost your product attributes and products in the search results by giving them a weight.
By product attribute
To define some weight for each one of your attributes, you can go to CatalogAttributes Manage Attributes .
Edit the attribute you want. In the Properties tab and Elasticsearch Settings subtab, you’ll be able to define a value from 1 to 10 depending on the weight you want to assign to it.