The _id field deprecated warning in the elasticsearch_dsl python package

I'm using a python client.
There's a Document of the document class, with a data field called id.
I've added a document to the default index, without defining a value for that id field. I was expecting ES to auto-populate that field.

I ran the following

search = Document.search()
search.aggs.bucket("External Ids", A('terms', field = 'external_id'))\
    .bucket("Ids",A('terms', field = 'id'))
response = search.execute()
response.aggs.to_dict()

and nothing showed up in the second bucket.
However, if I use field = '_id', then I get results on the second bucket, and the following warning:

elasticsearch/connection/base.py:200: ElasticsearchWarning: Loading the fielddata on the _id field is deprecated and will be removed in future versions. If you require sorting or aggregating on this field you should also include the id in the body of your documents, and map this field as a keyword field that has [doc_values] enabled
  warnings.warn(message, category=ElasticsearchWarning)
  • Why didn't ES auto-populate the id field?
  • How can I make the query above work, and give me a similar result but with the id field instead of _id?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.