# Bulk API update by query

**URL:** <https://discuss.elastic.co/t/bulk-api-update-by-query/93822>\
**Category:** Elasticsearch\
**Created:** [July 19, 2017, 5:52pm UTC](https://discuss.elastic.co/t/bulk-api-update-by-query/93822 "2017-07-19T17:52:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanlaff](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@seanlaff](https://discuss.elastic.co/u/seanlaff)\
**Post date:** [July 19, 2017, 5:52pm UTC](https://discuss.elastic.co/t/bulk-api-update-by-query/93822/1 "2017-07-19T17:52:14Z")

</div>

Is it possible to use update\_by\_query with the bulk api?

I'm constantly polling data from mysql and updating the relevant ES documents- however since I don't match on the document IDs (I match on various keys of a document), I have been using the update\_by\_query function.

I'd like to bulk these requests since I'm making thousands of them, but it doesn't seem possible to use these two features together.

Any advice would be appreciated.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 20, 2017, 8:57pm UTC](https://discuss.elastic.co/t/bulk-api-update-by-query/93822/2 "2017-07-20T20:57:38Z")

</div>

To my knowledge, I don't believe update-by-query works with bulk. In fact, it's essentially doing bulk updates under the hood. UPQ works by executing a query to find all matching documents, collecting the IDs, then issuing a bulk request with an update action for each document.

A bulk update-by-query could be _very_ expensive, since it would send off many search and bulk requests simultaneously.

Is there any way that you can tie the document's ID in elasticsearch to an ID in mysql? Update-by-query is useful, but also rather expensive. Doing thousands of them sounds like it will be putting a lot of strain on your cluster.

---

<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:** [August 17, 2017, 8:58pm UTC](https://discuss.elastic.co/t/bulk-api-update-by-query/93822/3 "2017-08-17T20:58:08Z")

</div>

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