Magento 2 Elasticsearch Catalog Search indexer process unknown error: Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true

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 !

This could interest you

Become a more social person