Back to Top

User Guide of Magento 2 Elasticsearch Module

You can include the Elasticsearch engine in your Magento 2 (Adobe Commerce) web store with the help of the Magento 2 Elasticsearch extension.

The elastic search engine is a highly scalable and open-source full-text search engine.

It enables quick storage, searching, and analysis of large volumes of data.

Also, it is a fast search engine that instantly displays the results of the given query.

Note: Elastic Search Engine v7.6 must be set up and functioning on the system before installing the Magento 2 Elastic search module.

Also, if you want to enhance your store with the AI-powered image search for products, you can check Magento 2 AI Image Search.

You can also check our Magento 2 Semantic Search extension to enhance your store with the feature of searching products using natural language queries. 

Video Tutorial of Magento 2 Elasticsearch

Watch the video tutorial below to understand Magento 2 Elastic Search extension workflow:

7jKVd2YmNms

Features of Magento 2 Elasticsearch Extension

  • The elastic search engine can quickly replace the function of the MySQL search engine.
  • The elastic server’s admin can easily update the data for products, categories, and CMS pages on the server.
  • The index type determines how the data is saved on the elastic server.
  • The admin will use a command line program to update website data on the elastic server.
  • The Frontend’s search type can be adjusted by the Admin to either Multi-Match Query or Simple Match Query.
  • Customers can search data by name, SKU, description, and a product short description if Multi-Match Query has been chosen as the search type.
  • Customers can only find the products by name or SKU if a simple Match Query is chosen.
  • The spell-checking feature in the Magento 2 Elasticsearch plugin allows the search engine to rectify keywords even when they are entered improperly.
  • Customers can search for products if they accidentally type the incorrect product name using the Did you Mean button. As a result, this feature will recommend to them all the products with the same product name that is nearby.
  • The admin can choose character filters to replace or delete unwanted characters from the search input.
  • The admin can also choose a multilingual language stemmer under the language stemmer in the Magento 2 Elastic Search extension.
  • The admin can choose And or Or as the operator for the multi-search, so results match every word or at least one word.

  • The admin can set a minimum match value to control how closely a product must match before it appears in the results.

  • Smart Search Mode applies optimized query algorithms and safe tokenization automatically, and it hides the manual query DSL overrides while enabled.

  • When enabled, out-of-stock products appear in a separate section below the in-stock results on the catalog search page.

Installation of Magento 2 Elastic Search Extension

Installation of the Magento 2 elastic search plugin is easy. Admin needs to select the app folder into the Magento root folder on the server shown in the snapshot.

1

#Run Commands

Once the plugin is installed, the admin has to run the following commands in the Magento2 root directory.

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento elastic:index -a reindex all 

After running the commands, the admin has to log into the admin panel and clear the cache, according to the screenshot below.

6

Language Translation

To translate the module language, navigate through src/app/code/Webkul/ElasticSearch/i18n and edit the en_US.csv file.

Thereafter, rename the CSV as “en_SA.csv” and translate all right side content after the comma in the Arabic language. After editing the CSV, save it.

Magento 2 PMarketplace ChatGPT Content Generator Installation 2

Now, upload it to the path src/app/code/Webkul/ElasticSearch/i18n where the installation of Magento 2 is on the server.

The module was translated into the Arabic Language. It supports both RTL and LTR languages.

The user can edit the CSV like the image below.

language translation i18 folder csv file

Admin configuration of Magento 2 Elasticsearch

After the successful installation of the Magento 2 Elastic Search extension on your Magento 2 store.

The admin will navigate through Stores > Configuration > Catalog > Catalog search > Search engine and then select Webkul Elasticsearch.

catalog search

Magento 2 Elasticsearch General Settings

Once the search engine got selected as Webkul Elasticsearch, the admin will navigate through Stores > Configuration > Webkul > Elastic Search Setting > General Settings.

general settings

Here the Admin has to enter/Select:-

  1. Add the elastic server hostname in the Host field.
  2. Port Number:- To configure the elastic server enter the port number.
  3. Index Prefix:- We are using an elastic search server on multiple websites. If we use an index prefix on websites, then at the time of re-indexing, that particular website data will not affect other websites.
  4. Check Connection Status:- Check the current status of the elastic server. 
  5. Reset Connection:- The connection will be reset if you choose this option, and all data will be deleted from the current elastic server. The administrator must manually reindex it by going to Elastic search > Index management.

Search Settings

Enable Smart Search Mode: Set this to Yes and Webkul applies optimized query algorithms with safe tokenization while hiding the manual query DSL overrides. Set it to No to set the multi-match type, operator, and minimum match yourself.

Show Out-of-Stock Products Separately: Set this to Yes to list sold-out products in their own section below the in-stock results on the catalog search page.

Allow Spell Correction in Search: Pick the fuzziness level for search, from Level 1 upward. Fuzziness lets the engine auto-correct spelling mistakes, so a wrong spelling still returns relevant products.

Select Search Filters: Choose which token filters apply to every search query. Pick from Elision Filter, Lowercase Filter, Synonym Filter, and Stop Word Filter, and select as many as you need.

enablesmartsearch

Enter Comma Separated List Elisions: Enter a comma separated list of elision articles, such as “l, d, t”. This works only when you select the Elision Filter and strips the leading articles from the term.

Use Stop Words Filter: Set this to Yes to drop common words from the search term, so a query like “shoes for men” matches on “shoes” and “men” without stopping on “for”.

Select Language Stemmer: Choose a stemmer that matches your store view language, from the 28 available including English, Arabic, German, French, Hindi, Italian, Norwegian, Portuguese, and Spanish.

Enter Comma Separated Words to Exclude from Stemming: Enter a comma separated list of words to skip stemming, such as “cats, catlike”. They keep their exact form, which helps with brand names and technical terms.

commaseperetedlist

Select Search Filters: Choose which character filters apply to every search query. Pick from Html Strip Char Filter, Mapping Filter, and Pattern Replace Filter to clean up unwanted input.

Enter Comma Separated List Of Filter Mappings: Enter a comma separated list of mappings, such as ٠ => 0, ١ => 1, ٢ => 2, ٣ => 3. Each key swaps with its value, and this works only when you select the Mapping Filter.

searchfilter

Multi-Match Query Configuration

These fields appear when Enable Smart Search Mode is set to No.

multimatch

Select Frontend Search Type: Choose how the store searches on the frontend. Multi Match Query searches across the fields you select below, while Simple Match Query looks at the product name and SKU only.

Select Fields For Multi Search: Choose the catalog attributes the multi-search evaluates. The default set is sku, description, short_description, url_key, and name, and a product appears when the search term matches any of them.

Select Multi Match Type: Choose the Elasticsearch scoring algorithm for the multi-search. Pick Best Fields, Most Fields, Cross Fields, Phrase, or Phrase Prefix, depending on how closely a product must match.

Select Operator For Multi Search: Choose AND when every term the customer typed must match, or OR when any single term is enough to include a product. Default: OR.

Minimum Should Match: Enter the percentage of query terms a product must match, for example 75%, to reduce low-quality results. A higher value returns fewer but more accurate matches. Default: 75.

Simple Match Query Configuration

Select Frontend Search Type: Simple Match Query restricts search to the product name and SKU only, ignoring the description and short description. It suits B2B portals and parts catalogs where buyers search by SKU or exact part names.

simplematch

Allow Spell Correction in Search: Pick the fuzziness edit distance the engine allows. Choose Level 0 for exact matches, Level 1 for one edit, Level 2 for two edits, or Auto, so a wrong spelling still returns relevant products.

Select Search Filters: Choose the token filters applied during analysis. Pick from Synonym Filter, Elision Filter, Lowercase Filter, and Stop Word Filter, and you can select more than one at a time.

Enter Comma Separated List Elisions: Enter a comma separated list of elision prefixes to strip, such as “l, d, m, t, s, n, qu” for French or Italian. This works only when you select the Elision Filter.

Use Stop Words Filter: Set this to Yes to remove high-frequency noise words such as and, the, and to from the search term before the query runs.

Enter Comma Separated List Of Stop Words: Enter a comma separated list of stop words to use. If you leave it empty, the module falls back to the Elasticsearch standard default dictionary.

Select Language Stemmer: Choose a stemmer for each store view locale to reduce words to their base root, so a search for running also matches run. Pick the one that matches your store language.

Enter Comma Separated Words to Exclude from Stemming: Enter a comma separated list of words or brand names to preserve without root reduction, such as “shoes, skis”, so they stay searchable in their exact form.

Select Search Filters: Choose the character filters applied before tokenization. Pick from HTML Strip Char Filter, Mapping Filter, and Pattern Replace Filter to clean up unwanted characters in the search term.

Enter Comma Separated List Of Filter Mappings: Enter key value pairs in key => value format to standardize characters, such as mapping Eastern Arabic numerals. This works only when you select the Mapping Filter.

Enter Pattern: Enter a regular expression to identify recurring noise or formatting in product text, such as (\d+)-(\d+) for hyphenated part numbers. This works only when you select the Pattern Replace Filter.

Enter Pattern To Replace With Filter Pattern: Enter the replacement string substituted for the pattern matches, such as $1$2 to unify hyphenated SKUs so 123-456 matches 123456. Leave it blank to strip the matches instead.

Note On Regular Expressions: A badly written regular expression could run very slowly or even throw a StackOverflowError and cause the node it runs on to exit suddenly, so test the pattern on a staging server first.

Search Suggestion in Magento 2 Elastic Search Extension

In search suggestions, with the help of keywords, customers can search categories, pages, or products.

Magento 2 Elasticsearch - search sugg

Magento 2 Elasticsearch Did You mean

When a customer enters the wrong product name, it will recommend all nearby products with the same product name to the customers. 

Shown in the below screenshot.

Magento 2 Elasticsearch - did-you-mean

Spell Correction in Search

The Elastic Search Engine will automatically correct keywords when they wrote incorrectly by the customer if the spell check is set to Level 1 or Level 2 by the admin.

Magento 2 Elasticsearch - product

Select Search Filters

There are four types of search filters to modify the search term provided by the customer. The admin can select the token filters.

  1. Synonym Filter

The admin has to navigate through Marketing > Search Synonyms.

search synonyms

Admin can create a new synonym group from here. For example, the admin has added synonyms for jeans and pants.

create synonym group

Now, the search engine will display all the results connected to any of these keywords if the customer searches for one of them.

Magento 2 Elasticsearch - products

2. Elision Filter- An elisions-removing token filter. For example, “L’avion” (the plane) will be parsed as “avion” (plane).

3. Lowercase Filter– A lowercase token filter that converts token text to lowercase.

4. Stop Word Filter– Stop words are removed from the search query. Examples of stop words are and, is, and to.

To learn more about token filters, please go through the following Link:

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenfilters.html

Select Language Stemmer

According to the language of the Magento 2(Adobe Commerce) store, the admin must choose the appropriate Language Stemmer. 

For example, if the store language is set as English, the customer can only search in English.

  • Select Language Stemmer: Choose the language for stemming words.
  • Enter comma separated words to exclude from stemming: List words to keep unchanged during stemming.

Select Character Search Filters in Magento 2 Elasticsearch

There are three types of character filters. That is used to remove unwanted characters from the search input.

image

ss

  1. HTML strip char filter– The HTML strip character filter strips off the HTML parts.
  2. Mapping Filter– The mapping filter swaps out the mapping keys with values. So, it will eliminate any character from the mapping in the Magento 2 Elasticsearch module.
  3. Pattern Replace Filter– The Pattern Replace Filter functions similarly to the Mapping Filter. The main difference is that it replaces patterns instead of mapping them. To replace characters, it makes use of a regular expression
  4. Enter Comma Separated List Of Filter Mappings: List multiple filter rules, separated by commas.
  5. Enter Pattern: Define the text or pattern to search for.
  6. Enter Pattern To Replace With Filter Pattern: Define the text or pattern to replace the found pattern.

To learn more about the character filters, please go through the following URL:

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-charfilters.html

Index Management of Magento 2 Elasticsearch

Moreover, the admin can navigate through elastic search > index management.

elastic indexes

The admin can change the status of the index type. For the index type, the admin has two options: update on save mode or update on a schedule.

For example, the admin must change the status of a product index type whenever he adds a new product.

So, the admin can also use the system command line features if they have to change a large amount of data.

elastic-search.

That is all for the Magento 2 Elasticsearch module. Still, have any issues feel free to add a ticket and let us know your views to make it better at webkul.uvdesk.com.

Current Product Version - 5.0.5

Supported Framework Version - Magento 2.0.x, 2.1.x, 2.2.x,2.3.x, 2.4.x

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home
On this page

Table of Content

Back to top