User Tools

Site Tools



For more details see the Elastic Search for Magento 2 extension page.

Elastic Search for Magento 2

Elastic Search for Magento 2 is an advanced solution which provides your store with highly accurate, fast and flexible search.

  • Autocomplete suggestions & spell corrections
  • Partial search by SKU, name, attributes, category
  • Product attribute weight settings
  • Flexible indexing management
  • Multi-lingual search
  • Responsive & mobile-friendly

Before Installing

Please, consider that there are three main entities, which constitutes the extension's work:

  • Elasticsearch engine, which version should be equal to or greater than 5.x (The extension supports Elasticsearch 5.x, 6.x);
You can check the version via curl request, for example:
  • Elasticsearch-php, which is the Elasticsearch library;
Note, that the Elasticsearch-php library and Elasticsearch engine itself are different things. In its composer.json dependencies, the extension has “elasticsearch/elasticsearch”: “>=5.1” specified, which means that 5th version of the PHP-library will be installed via Composer. However, along with that, you have to install Elasticsearch engine as well.
  • Amasty Elastic Search for Magento 2 extension, which is a configurable bridge between Elasticsearch engine and Magento platform.

Installing ElasticSearch engine

Prior to all the extension's settings, please, make sure that Elasticsearch engine is properly installed.
If you are experiencing any difficulties with the Elasticsearch engine installation process, you can get our Elasticsearch installation service.

Elasticsearch is provided in the various packages formats. The most commonly servers work on Debian-based or RPM-based systems.

Install ElasticSearch with Debian Package

Debian Package can be used to install Elasticsearch on any Debian-based system such as Debian and Ubuntu. You can install and run the Elasticsearch Debian package with the following:

shasum -a 512 -c elasticsearch-6.3.0.deb.sha512 
sudo dpkg -i elasticsearch-6.3.0.deb
sudo update-rc.d elasticsearch defaults 95 10
sudo -i service elasticsearch start
For more details on the installation aspects, please, visit the official Elasticsearch documentation.

Install ElasticSearch with RPM

It can be used to install Elasticsearch on any RPM-based system such as OpenSuSE, SLES, Centos, Red Hat, and Oracle Enterprise. The RPM for Elasticsearch v6.3.0 can be downloaded from the website and installed with the following commands:

shasum -a 512 -c elasticsearch-6.3.0.rpm.sha512 
sudo rpm --install elasticsearch-6.3.0.rpm
sudo chkconfig --add elasticsearch
sudo -i service elasticsearch start
For more details on the installation aspects, please, visit the official Elasticsearch documentation.

Install ElasticSearch on Magento 2 Enterprise

The soluction is for Magento 2 EE 2.1.X. For 2.2.X and above no additional actions required.

As Magento 2 Enterprise Edition utilizes its own ElasticSearch module, you will need to implement certain modifications before installing the ElasticSearch by Amasty.

Please, replace the line

"elasticsearch/elasticsearch": "~2.0",


"elasticsearch/elasticsearch": ">=2.0",

in the following files:

  • /vendor/magento/module-elasticsearch/composer.json
  • /vendor/composer/installed.json

Then, execute the following:

composer clearcache
composer require
elasticsearch/elasticsearch ~5.1

Now, the installation process should be completed successfully.

To manage a connection to Elastic Search, go to Admin Panel > Stores > Configuration > Elastic Search > Connection

To enable the extension, in the Search Engine field, select the Amasty ElasticSearch. Alternatively, select MySQL, to disable the extension.

Elasticsearch Server Hostname - Specify a host name or IP address of a machine that runs Elasticsearch. (localhost or by default).Get this value via Magento Cloud.

Elasticsearch Server Port - Set the Elasticsearch web server proxy port. In our example, the port is 9200.Get this value via Magento Cloud.

Elasticsearch Index Prefix - Specify a particular prefix for each store that you employ elastic search for.

I.e. If you use a single Elasticsearch instance for more than one Magento installation (for instance, Staging and Production environments), specify a unique prefix for each installation.

Enable Elasticsearch HTTP Auth - Select Yes, if you have enabled authentication for your Elasticsearch server. Specify a user name and password in the pop-up fields.

Elasticsearch Server Timeout - Set the timeout.

Click Test Connection.

Autocomplete suggestions & Spelling correction

To configure Elastic Search functionality, go to Admin Panel > Stores > Configuration > Elastic Search > Catalog

Wildcard Type - Specify the type of the autocomplete suggestion - the part of a word which will be auto-completed. Three types are available to set:

Wildcard After - Specify a number of symbols, after which an autocomplete suggestion will be applied.

Autocomplete suggestions after 3 symbols.

Spell Correction - Specify a number of symbols, after which a spell correction will be applied.

Spell correction after 4 symbols.

Max Number of Search Results - Specify the maximum number of items in the search results.

Set 0 to use default Magento limitation, which is 10000 items.

Allow Special Characters - Enable a long-tail search. The search will include the hyphens, slashes and any symbols. The feature provides precise results, when searching by SKU and MPN (manufacturer part numbers).

  • A sample of the precise long-tail search by SKU.
  • Note that the default search will not return any results for 24-MB04 request as it is based on the default product labels from a database, while the long-tail feature analyzes the keywords by patterns and “fixes” the query, returning the precise search results.

Advanced Query Settings

Add a product attribute

A product attribute in advanced query settings.

To add a product attribute to a search query configuration, please go to Admin Panel > Stores > Attributes > Product > Select a needed product attribute > click a tab Storefront Properties > Enable Use in Search

How to add a product attribute to a search query settings (watch full screen).


Specify the search type preferences for each product attribute:

In case both Wildcard and Spell Correction are set to Yes, only Wildcard search type will be applied as having higher search priority.
Consider, that shoppers don't have to input neither asterisks, nor boolean operators in a search query. The functionality is fully implemented in the search logic.
  • Wildcard search presupposes that shoppers can input a half-finished word, and get a relevant result.
  • Match Mode is how the words in a search query are combined. Shoppers don't have to input AND/OR in a search query. Go to match mode settings.

Product Name attribute with Wildcard vs with Spell Correction

How does a search work for a Name attribute with auto-suggestion vs with spell correction (watch full screen)

Match Mode

Think over how would you like the keywords in a search query to be combined for each product attribute.

How it works?

For instance, a customer searches your web store looking for a velvet jacket. As you specify a boolean type for a Product Name attribute:

  1. AND logic will return only results that contain both velvet and jacket
  2. OR logic will return results that contain either velvet or jacket (velvet shoes, denim jacket, etc)
Search results for 'radiant tee' sample
  • with AND logic
  • with OR logic

Synonyms & Stop words

To build a dictionary of synonyms, navigate to Admin Panel > System > Manage Synonyms

Click Add New Synonym to input a group of words that will be regarded equally by a search logic. Separate them with commas.

Select a Store View.

You can switch to edit an entry by clicking Select in Action column on the synonyms' grid.

You can import a CSV file with synonyms dictionary.

Have a look at a search by synonyms in action (Watch full screen).

Manage Relevance Rules

To manage boost rules, navigate to Admin Panel > System > Search Page Relevance Rules.

Click Add New Rule to specify search and return conditions for a new promo rule.

In the Action column (Select drop-down) choose Edit, to edit the existing rules.

Specify the name for a relevance rule - input Title. Note, that it is used mainly for admin.

Enabled - Enable or disable a rule with a toggle.

Note, that you might need to re-index your Magento for the changes to take effect.

Website - Specify the particular stores, where you want the rule to be applied. Select from drop-down a needed store.

Activate - Set the dates (from-to), use a pop-up calendar or input directly with numbers.

Product Relevance - There are two modes available to work with relevance rules: Increase by and Decrease by:

  • Select Increase by to boost a certain group of products in the search results;
  • Select Decrease by to lower a product or a certain group of products in the search results;

Specify to what extend you want to boost or lower the products by setting a number from 1 to 100.

Elasticsearch engine uses so called Scores, when it manages the order of the search results' return. The module can increase or decrease these scores selectively by a set number of times.

Conditions - Set the conditions, according to your marketing needs.

  • To boost or lower a certain product in the search results, you can click + button and select SKU from the condition drop-down, and specify its value.
  • To boost or lower a certain group of products, click + button and select a Category from the condition, and specify a pass to the directory, where this group of products belong to. Next, additionally, you can select a Brand, for instance, and specify it. Also, in case this is a new collection, select NEW and set to Yes.

Go to Admin Panel → Stores → Configuration → Search Pro, to configure the advanced search features.

Popup width (px) - Specify the width of a search pop-up window to make it fit your theme and page layout elements.

Min characters - Set the minimal number of characters that customers should type in to trigger the search pop-up. By default, the number is three.

Enable Redirect from 404 to Search Results - Enable the option to redirect customers to the store search results from the broken URL instead of the 404 Not Found page.See sample

Custom URL Key for Default Search Results Page - Enable to set SEO-friendly short URLs.

The extension returns shorter URLs like instead of default

SEO key - specify the URL alias for the search results' page.

Enable Tabs on the Search Result Page - To enable tabs, that sort search results by Category, CMS, and Landing on the search results page, set to Yes.

A front-end sample of tabs:

Search Attributes

Include any available product attributes in the search algorithm.

Set a priority (weight) for each attribute.

If there is a color attribute with weight 10 and description attribute with weight 5, and the query is red, search results will be more visually relevant, because the algorithm will choose color attribute prior to the words in description.
  • Press Add button to add one more attribute
  • Select Attribute from a drop-down
  • Set its Weight from 1 to 10 - select from a drop-down
  • Delete an attribute by clicking an icon in Action column

Recent Searches

Show on first click - Set to Yes to let customers see the Recent Searches block in the autocomplete popup once they click on the quick search field.

Title - Set a title and a position for Recent searches block.

Max Results - Set the maximal number of search results that will be displayed in the search autocomplete popup.

Display Recent Searches in a pop-up

Enable the Popular Searches block to pop-up by the first customer's click.

A sample


Enabled - Enable to let the extension display the categories that contain target items in the autocomplete popup.

Specify Categories block title, position and the max number of displayed results.

Description Length - Specify the maximal number of characters for category names and descriptions that will be shown is the search popup.

When mouse hover over a category link, the directory levels are displayed.

СMS Pages

Enabled - Set to Yes to enable search on CMS pages and display search results in the autocomplete popup.

Max Results - Specify the Title, Position and the Max number of displayed results.

Specify the maximal number of characters for headings and descriptions that will be shown is the search popup.


Enabled - Set to Yes to enable search in products and display search results in the autocomplete popup.

Max Results - Specify the title, position and the max number of displayed results.

Show Reviews - Enable reviews display in the autocomplete popup.

Enable 'Add to Cart' Button - Show Add to cart button in the popup.

Redirect to Product Page - Set to Yes to enable redirection in case there is only one search result available.

To go to a product page, when the extension returns only one result in a search pop-up, press Enter.

Show 'Out of Stock' Products Last - Enable a feature to place the out-of-stock items last in the search results.

To make this feature works properly with out-of-stock items being displayed correctly, please make sure that out-of-stock items' visibility is enabled.
  1. Go to Admin Panel > Stores > Configuration > Catalog > Inventory > Stock Options
  2. Navigate to a Display Out of Stock Products field > Uncheck Use system value and set to Yes.
Out-of-stock items displayed last in the search results, a sample.

Landing Pages

You can enable an advanced search by landing pages on your web store, if you have Amasty Landing pages for Magento 2 extension installed.

Search Landing Pages

Note, that in order to have this functionality performing properly, the Landing Pages for Magento 2 extension should be installed.

To display Landing Pages instead of the search results page, go to Admin Panel > Marketing > SEO & Search > Search Terms > Press Add New Search Term.

  • Input expected Search Query;
  • Specify the Store;
  • Redirect URL - input the URL of the landing page.


Enabled - Set to Yes to enable search by brands and to display a brand section in the search window pop-up.

Title - Input a name for the section in the search pop-up, where the brands' results will be displayed.

A brand sample section in the search pop-up:


Enabled - Set to Yes to enable search by blog pages and to display a blog section in the search window pop-up.

Title - Input a name for the section in the search pop-up, where the blog results will be displayed.

Custom Layout

Text - Choose the necessary color for each element of the autocomplete window.

Color Picker - Click on the field to display the color picker tool.

Index Management

To to configure the indexing of your catalog, go to System → Tools → Index Management


To prevent search engines (Google, Bing, Yahoo, etc.) from needlessly indexing Magento catalog search results page(s) and advanced search results page(s) we added the code to app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/local.xml.

  • If this file does not yet exist in your custom theme you can create it and Magento will automatically include it.
  • If this file already exists in your custom theme then copy everything except the first line XML declaration and elements into your copy of local.xml.
magento_2/elastic_search.txt · Last modified: 2018/08/14 07:26 by milosh