Elastic Search for Magento Developer

As of Magento 2.4 Magento does not support MySql as a Search Engine. Now, you must install and configure Elasticsearch as your search engine before upgrading to 2.4.

The below are the two primary actions involved with magento integration with elastic search which we will see in detail.

  • Push Data
    • The product data from Magento is pushed to elastic search through catalogsearch_fulltext indexing.
  • Fetch Data
    • Through query and aggregation search, Ex graqlql query, plp etc

We can use any REST API client for interacting with Elasticsearch. Following are some sample http methods we will be using to interact

  • GET : Used to retrieve records based on query
    • GET 'http://localhost:9200/magento2_product_1/_search'
    • GET 'http://localhost:9200/*/_settings
  • POST : Used to update the existing record in Indices
    • POST 'http://localhost:9200/indexname/_doc'
  • PUT : Used to create and update the records
  • DELETE : To remove the existing record from indices

Magento_Elasticsearch is the magento core module that handles the elastic search functionality. This module internally uses the third party php client https://github.com/elastic/elasticsearch)to communicate with the elastic search instance.

Code Reference

  • \Elasticsearch\Namespaces\BooleanRequestWrapper::performRequest
  • \Elasticsearch\Transport::performRequest
    • The place where actual request that is triggered to elastic search

In the below articles we will look in to the elastic search concepts and how its works with Magento.

Leave a Reply

Your email address will not be published.