# How to execute BULK UpdateByQuery using java api - Elasticsearch 5.x

**URL:** <https://discuss.elastic.co/t/how-to-execute-bulk-updatebyquery-using-java-api-elasticsearch-5-x/94673>\
**Category:** Elasticsearch\
**Created:** [July 26, 2017, 5:18pm UTC](https://discuss.elastic.co/t/how-to-execute-bulk-updatebyquery-using-java-api-elasticsearch-5-x/94673 "2017-07-26T17:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarnaout](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@aarnaout](https://discuss.elastic.co/u/aarnaout)\
**Post date:** [July 26, 2017, 5:18pm UTC](https://discuss.elastic.co/t/how-to-execute-bulk-updatebyquery-using-java-api-elasticsearch-5-x/94673/1 "2017-07-26T17:18:12Z")

</div>

I have multiple updateByQuery requests, and looking for a way to group them together, and then execute (for performance reasons).

## Example:

QueryByField || field11111 || field222222 || field333333 ||

xxxxxxxxxxxx || newValue || newValueee || newValuee ||

yyyyyyyyyyyyy || newValue || newValueee || newValuee ||

zzzzzzzzzzzzzz || newValue || newValueee || newValuee ||

As of now, seems like I'll have to do the following query for each one of lines above:

UpdateByQueryRequestBuilder updateByQueryRequestBuilder = UpdateByQueryAction.INSTANCE.newRequestBuilder(client);  
updateByQueryRequestBuilder  
.source("myIndexName")  
.filter(QueryBuilders.matchQuery("QueryByField","xxxxxxxxxxxx"))  
.script(new Script("ctx.\_source.field11111 = "newValue""))  
.get();

But I was wondering, is there something similar to what we do with UpdateRequest & BulkRequestBuilder that can be used for UpdateByQuery?

---

<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 23, 2017, 5:18pm UTC](https://discuss.elastic.co/t/how-to-execute-bulk-updatebyquery-using-java-api-elasticsearch-5-x/94673/2 "2017-08-23T17:18:27Z")

</div>

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