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
es_mapping_error_output.txt
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:
example.py
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
example.txt
TypeError: put_mapping() got an unexpected keyword argument 'include_type_name'you need to upgrade your elasticsearch python library, e.g. using
example.sh
pip install -U elasticsearchCheck out similar posts by category:
Databases, ElasticSearch, Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow