# The \_id field deprecated warning in the elasticsearch\_dsl python package

**URL:** <https://discuss.elastic.co/t/the-id-field-deprecated-warning-in-the-elasticsearch-dsl-python-package/312785>\
**Category:** Elasticsearch\
**Created:** [August 24, 2022, 9:41am UTC](https://discuss.elastic.co/t/the-id-field-deprecated-warning-in-the-elasticsearch-dsl-python-package/312785 "2022-08-24T09:41:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivo\_Tavares](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivo_tavares/32/110022_2.png) [@Ivo\_Tavares](https://discuss.elastic.co/u/Ivo_Tavares)\
**Post date:** [August 24, 2022, 9:41am UTC](https://discuss.elastic.co/t/the-id-field-deprecated-warning-in-the-elasticsearch-dsl-python-package/312785/1 "2022-08-24T09:41:36Z")

</div>

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

```auto
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:

```auto
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`?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 21, 2022, 9:42am UTC](https://discuss.elastic.co/t/the-id-field-deprecated-warning-in-the-elasticsearch-dsl-python-package/312785/2 "2022-09-21T09:42:23Z")

</div>

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