Magento 2 Elasticsearch

Magento 2 Elasticsearch

Magento 2 Elasticsearch tutorial on how to use and configure as the primary search engine.

" Elasticsearch » Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.”

In translation to Magento 2 it’s a search engine that can be used to provide better results and search speeds.

Setup #

Install #

Configuration #

  1. Log in to the Magento Admin.
  2. Go to Stores > Settings > Configuration
  3. Select Catalog > Catalog.
  4. Opend the Catalog Search tab.
  5. In the select Search Engine list, select the corresponding Elasticsearch version.

With the above in place you will have the following inputs available for specifying:

  • Elasticsearch Server Hostname - hostname or IP address of the machine running Elasticsearch.
  • Elasticsearch Server Port - Elasticsearch web server proxy port.
  • Elasticsearch Index Prefix - Elasticsearch index prefix.
  • Enable Elasticsearch HTTP Auth - Set only if your Elasticsearch server requires authentication.

Indexing #

After the Configuration step you must reindex the catalog search index and the full page cache. This can be done via admin and command line.

Cache Refresh Admin #

  1. Login into Admin area.
  2. In the Admin, click System > Cache Management.
  3. Click on the checkbox that is next to Page Cache.
  4. From the Actions list on top right, select Refresh.
  5. Click Submit.

Cache Refresh Command Line #

To refresh the Full Page Cache after enabling Elasticsearch you can use command bellow:

$ bin/magento cache:clean full_page

This will output something like:

Cleaned cache types:

Reindex Command Line #

Reindexing after configuring Elasticsearch can be done only via command-line, the option to reindex via admin has been removed by the Magento team. Bellow will reindex the catalog search index only.

$ bin/magento indexer:reindex catalogsearch_fulltext

This will output something like:

Catalog Search index has been rebuilt successfully in 00:00:05

It is important to have Magento 2 Cron configured properly as Magento uses it to keep indexers in sync with main data.

Module #

Published: Dec 23, 2018. Updated: September 10, 2020.

Magento 2 Installation

How to setup and install Magento 2 in you server


Magento 2 Mode

The Magento 2 store can run in different modes, depending on the environment, that can increase speed load.

Magento 2 Import

Magento 2 Import

Magento 2 Import tutorial and How To for Products Import, Categories Import, Customers Import or Tax Rates Import.


Magento 2 API

Magento 2 API tutorial for setting up authentication, Authentication types and URLs that can be used.


Magento 2 Cache

Magento 2 Cache tutorial on different usage scenarios and why Cache should be enabled on your store.

Magento 2 Varnish

Magento 2 Varnish

Magento 2 Varnish. What is Varnish and how it can be used and configured in a Magento 2 store.

Hire us

Need help with Magento 2 Elasticsearch ?


Technologies we work with

Magento is an open-source e-commerce platform written in PHP
PHP is a popular general-purpose scripting language that is especially suited to web development.
MySQL is an open-source relational database management system.
Redis is an in-memory data structure project implementing a distributed, in-memory key-value database with optional durability.
Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as APIs.
Google Tag Manager is a free tool that allows you manage and deploy marketing tags on your website / app
Google Analytics is a web analytics service offered by Google that tracks and reports website traffic
Elasticsearch is a search engine based on the Lucene library.