Logo Wyomind Magento workshop

Add-ons for Magento®

The Elasticsearch® extension allows you to improve the default Magento search results and to enhance search results relevancy.

134 Reviews

Elasticsearch suite for Magento 2

expand

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 these functionalities 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.

Install Elasticsearch

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.

Run Elasticsearch

To run Elasticsearch, open a console and run the following command:

cd elasticsearch-<version>./bin/elasticsearch

If you’re running Elasticsearch on Windows, simply run:

bin\elasticsearch.bat

Test Elasticsearch

You can easily test if the Elasticsearch engine is reached by opening a new terminal window and running the following:

curl 'http://localhost:9200/?pretty'

You should then get:

You now have an Elasticsearch node up and running.

You can also check the official documentation to install Elasticsearch. 

STEP 2: Enable the Elasticsearch method

To configure Elasticsearch in a general way, go to:

SystemConfigurationCatalogCatalogSearch

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 ("Do 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. 
  • Fuzzy Query Mode
    You have the possibility to choose the fuzzyness level. For example:
    0, 1, 2: the maximum allowed Levenshtein Edit Distance (or number of edits)
    AUTO: should generally be the preferred value. Generates an edit distance based on the length of the term.
    For lengths:
    0..2: must match exactly
    3..5: one edit allowed
    >5: two edits allowed

Feel free to take a look to the Elastic documentation for the Fuzzy query mode.

  • Analyze SKUs
    When Fuzzy Query is enabled, you have the possibility to analyse the skus. The skus will be analyze like other product attributes. It is useful if SKUs are multi-part values, such as XXX-YYY-ZZZ. If you don't want to analyze SKUs, then the SKU attribute is considered as one single word.

Manage your Indexes

The Elasticsearch extension adds 3 more indexes that you can find in:

SystemIndex 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:

SystemConfigurationWYOMINDElasticsearch.

General Settings

In the General Settings subtab, you will be able to Enable Response Header. This will enable a custom response header for debug purpose.

Autocomplete Settings

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, 3 additional options will be displayed:

  • Enable Fast Autocomplete
    Use the fast autocomplete (with a payload during indexation).
  • Autocomplete labels
    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.
    That 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.
  • Enable Autocomplete Suggestions
    You can enable the suggestions in the autocomplete (do you mean?).
  • Suggestions limit
    You can define the maximum number of suggestions to display. 

Below is what you should get with the above example:

Product Settings

With the Elasticsearch extension, you can make your products searchable in the autocomplete 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.
  • Autocomplete Limit
    Define the maximum number of results displayed in the autocompletion. For example 3.
  • Display image
    To display product image in the autocomplete.
  • 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.
  • Index product custom options
    Product custom options will be indexed and searchable. This requires a new indexation.

Category Settings

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.
  • Autocomplete Limit
    Define the maximum number of results displayed in the autocompletion. For example 2.

  • 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.

CMS Settings

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.
  • Autocomplete Limit
    Define the maximum number of results displayed in the autocompletion. For example 3.

  • 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 products in order to refine the search results

The Elasticsearch 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.

By product

The Elasticsearch extension allows you to easily boost your product in the search results by giving them a weight.

You can apply a weight for the product in:

CATALOGMANAGE PRoductS Edit  Elasticsearch tab