I am facing issue when enabling elastic search in magento 2.3 with latest elastic version 7.3.1. All products are hidden in frontend and search not working and when trying to do manual indexing getting this 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}

  • Hey, Did you found any solution? Commented Apr 14, 2020 at 11:44

3 Answers 3


Go to Magento\Elasticsearch6\Model\Client\Elasticsearch

Find function addFieldsMapping approx line number 241

Add new element to $params array

'include_type_name' => true,

This will resolve your error

$params = [
    'index' => $index,
    'type' => $entityType,
    'include_type_name' => true,

Types in requests is deprecated in Elasticsearch 7.x version.

  • Types are deprecated in APIs in 7.x, with breaking changes to the index creation, put mapping, get mapping, put template, get template and get field mappings APIs.
  • For instance, indexing a document no longer requires a document type. The new index APIs are PUT {index}/_doc/{id} in case of explicit ids and POST {index}/_doc for auto-generated ids.

    Note that in 7.0, _doc is a permanent part of the path, and represents the endpoint name rather than the document type.

  • The include_type_name parameter in the index creation, index template, and mapping APIs will default to false. Setting the parameter at all will result in a deprecation warning.
  • The _default_ mapping type is removed.

Switching to Elasticsearch 6.x is one of the best alternative as this will be endpoint update for the elastic search libraries (https://github.com/elastic/elasticsearch-php).

It can be achievable to use include_type_name is an elastic search flag but it will attract a deprecated warning.

For debugging purpose, one should make a change in the methods (i.e. addFieldsMapping, deleteMapping ) of the following class by creating a override module for elasticsearchfix-7.

  • 1
    the solution right now is to only downgrade the version to 6.*, other than that i don't found any solution. Commented Sep 3, 2019 at 6:17
  • Hello @Sandip. Do you know how to compatible elasticsearch 7 version? Which changes should I need to add? Commented Apr 14, 2020 at 10:18
  • A Separate module is needed like Magento/ElasticSearch6 with composer require "elasticsearch/elasticsearch": "~7.6", into main composer.json file
    – sandip
    Commented Apr 14, 2020 at 10:37

This has fixed the problem Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true. for me in Magento 2.4.2-p1:

n98-magerun2.phar  config:store:set  catalog/search/engine  elasticsearch7
n98-magerun2.phar  config:store:set  catalog/search/elasticsearch7_server_hostname  '<elastic_host>'
n98-magerun2.phar  cache:clean  config

If you don't have n98-magerun2.phar installed, more info can be found here. You can also switch to ElasticSearch 7 using the Admin interface.

  • Instead of n98-magerun2.phar, you could use magento default command, Ex: n98-magerun2.phar config:store:set catalog/search/engine elasticsearch7, you could use php bin/magento config:set catalog/search/engine 'elasticsearch7' instead.
    – fudu
    Commented Oct 20, 2021 at 7:49
  • Also, set elastic search to correct version worked for me. In my case, it was elasticsearch7, you could set in Admin -> Store -> Configuration -> Catalog -> Catalog -> Catalog Search.
    – fudu
    Commented Oct 20, 2021 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.