# \_update\_by\_query doesn't return a list of affected IDs and Indices

**URL:** <https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820>\
**Category:** Elasticsearch\
**Created:** [September 3, 2019, 10:29am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820 "2019-09-03T10:29:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![markb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markb/32/53487_2.png) [@markb](https://discuss.elastic.co/u/markb)\
**Post date:** [September 3, 2019, 10:29am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/1 "2019-09-03T10:29:24Z")

</div>

I want to update records by running "\_update\_by\_query" and after that receive the list of affected ID's and indices like it happens when creating new record.  
It would be also nice to have returning the selected fields from the affected records.

The exact \_update\_by\_query request doesn't matter here, you can run any request with the same result.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 3, 2019, 11:00am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/2 "2019-09-03T11:00:31Z")

</div>

The update by query response does not contain any ids, but you could update a field as part of the update by query task, and then query for that field after the update is finished.

---

<div class="post-metadata">

**Author:** ![markb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markb/32/53487_2.png) [@markb](https://discuss.elastic.co/u/markb)\
**Post date:** [September 3, 2019, 11:28am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/3 "2019-09-03T11:28:14Z")

</div>

Yes, I know.  
But I want to do it by 1 request.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 4, 2019, 7:35am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/4 "2019-09-04T07:35:52Z")

</div>

as written above, that is not possible. Out of curiosity: What is the problem with the mentioned workaround, that will allow you to do what you need to? Why doesn't that work in your case?

---

<div class="post-metadata">

**Author:** ![markb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markb/32/53487_2.png) [@markb](https://discuss.elastic.co/u/markb)\
**Post date:** [September 4, 2019, 11:07am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/5 "2019-09-04T11:07:28Z")

</div>

In my query I have an unknown index and known id.  
After update I want to know the exact index name where I've updated the record for the following updates.  
If it is impossible I'll have to split \_update\_by\_query request into 2 requests - search and update.

---

<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:** [October 2, 2019, 11:07am UTC](https://discuss.elastic.co/t/update-by-query-doesnt-return-a-list-of-affected-ids-and-indices/197820/6 "2019-10-02T11:07:28Z")

</div>

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