How to fix ElasticSearch 'Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true'
Problem:
You want to create a mapping in ElasticSearch but you see an error message like
elasticsearch.exceptions.RequestError: RequestError(400, 'illegal_argument_exception', 'Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true.')
Solution
As already suggested in the error message, set the include_type_name
parameter to True
.
With the Python API this is as simple as adding include_type_name=True
to the put_mapping(...)
call:
es.indices.put_mapping(index='my_index', body=my_mapping, doc_type='_doc', include_type_name=True)
In case you now see an error like
TypeError: put_mapping() got an unexpected keyword argument 'include_type_name'
you need to upgrade your elasticsearch
python library, e.g. using
sudo pip3 install --upgrade elasticsearch