How to increase ElasticSearch total field limit using Python API
When using ElasticSearch, you will sometimes encounter an Limit of total fields [1000] has been exceeded
when you insert a large document.
One solution that often works for real-world scenarios is to just increase the default limit of 1000
to, for example, 100000
to account for even the largest documents.
How this can be done is, however, not well-documented for the ElasticSearch Python API. Here’s how you can do it:
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.put_settings(index="my-index", body={
"index.mapping.total_fields.limit": 100000
})