Learn why this exception is thrown during indexing of the catalog of products in Magento 2 using Elasticsearch.

During the reindex of your catalog of products in your Magento 2, using the terminal:

php bin/magento indexer:reindex

The Catalog Search indexer process will throw an Elasticsearch error:

Catalog Search indexer process unknown error:
{  
   "error":{  
      "root_cause":[  
         {  
            "type":"illegal_argument_exception",
            "reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
         }
      ],
      "type":"illegal_argument_exception",
      "reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
   },
   "status":400
}

This problem is caused by the usage of an unsupported version of Elasticsearch in Magento 2. For example, it usually happens when you have Elasticsearch 7.x installed, but till the date Magento supports only the version 5.x and 6.x.

Solution

The only solution to prevent this exception from appearing in the current version of Magento 2 till the date, is to use only an officially supported version of Elasticsearch (6.x or 5.x). If you use a recent version of Elasticsearch, for example the 7.x, which is not supported by magento, the exception will appear everytime you rebuild the search indexes.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors