# UpdateByQuery API Response returns wrong status

**URL:** <https://discuss.elastic.co/t/updatebyquery-api-response-returns-wrong-status/223611>\
**Category:** Elasticsearch\
**Created:** [March 14, 2020, 11:16am UTC](https://discuss.elastic.co/t/updatebyquery-api-response-returns-wrong-status/223611 "2020-03-14T11:16:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Om\_S\_Patel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/om_s_patel/32/64451_2.png) [@Om\_S\_Patel](https://discuss.elastic.co/u/Om_S_Patel)\
**Post date:** [March 14, 2020, 11:16am UTC](https://discuss.elastic.co/t/updatebyquery-api-response-returns-wrong-status/223611/1 "2020-03-14T11:16:41Z")

</div>

I am facing issue with UpdateByQuery API while trying to update a document which doesn’t exist in Elasticsearch

Problem description

Step 1 - We are creating one index for each day like test\_index-2020.03.11, test\_index-2020.03.12… and we maintain eight days(today’s as well as last week seven days) indexes.

Step 2 - When data arrives(reading one by one or in a bulk from Kafka topic) either we need to update(which may exist in any one of the 8 days indexes) if data already exist with given ID or save it if not exist(to current day index).

Solution I am trying currently when data arrives one by one:

-\>Using UpdateByQuery with inline script to update the doc

-\>If BulkByScrollResponse returns Updated count 0, then save the doc

Issues:

1. 

Even if doc doesn’t exist still I can see BulkByScrollResponse returns updated field as non-zero(1,2,3,4…) as follows

BulkIndexByScrollResponse[sliceId=null,updated=1,created=0,deleted=0,batches=1,versionConflicts=0,noops=0,retries=0,throttledUntil=0s]

Due to this unable to trigger document save request.

1. 

How to approach if bulk of documents(having set of different doc IDs) need to be updated with their respective content with single request? Will I be able to achieve with UpdateByQuery?

Note: Considering the amount of data to be processed per hour we need to avoid multiple hits to Elasticserach

Please suggest solution for the above mentioned issues.

---

<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:** [April 11, 2020, 11:16am UTC](https://discuss.elastic.co/t/updatebyquery-api-response-returns-wrong-status/223611/2 "2020-04-11T11:16:43Z")

</div>

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