# Update by Query - Python/Java client

**URL:** https://discuss.elastic.co/t/update-by-query-python-java-client/22051
**Category:** Elasticsearch
**Created:** [February 9, 2015, 10:57pm UTC](https://discuss.elastic.co/t/update-by-query-python-java-client/22051 "2015-02-09T22:57:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ap1](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Ap1](https://discuss.elastic.co/u/Ap1)
#### Post date: [February 9, 2015, 10:57pm UTC](https://discuss.elastic.co/t/update-by-query-python-java-client/22051/1 "2015-02-09T22:57:50Z")

</div>

I need to update tags in docs based on query search. I am able to do it  
using the update by query plugin.

Is there a way to do it using Python or Java API client.

Here is the query that works perfectly fine. Search for a phrase and update  
a tag.

curl -XPOST 'localhost:9200/index/type/\_update\_by\_query' -d '{  
"query" : { "match\_phrase" : { "content" : "michael aronstein" } },  
"script" : "ctx.\_source.tags += tag",  
"params" : {  
"tag" : "ABC"  
}  
}'

Amay

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b755711b-16e8-41e1-98b6-38f16b8b2031%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b755711b-16e8-41e1-98b6-38f16b8b2031%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 10, 2015, 5:55am UTC](https://discuss.elastic.co/t/update-by-query-python-java-client/22051/2 "2015-02-10T05:55:41Z")

</div>

If you add the plugin to your Java project you can probably use [https://github.com/yakaz/elasticsearch-action-updatebyquery/blob/master/src/main/java/org/elasticsearch/client/UpdateByQueryClientWrapper.java](https://github.com/yakaz/elasticsearch-action-updatebyquery/blob/master/src/main/java/org/elasticsearch/client/UpdateByQueryClientWrapper.java)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 9 févr. 2015 à 23:57, Ap [usc90909@gmail.com](mailto:usc90909@gmail.com) a écrit :
> 
> I need to update tags in docs based on query search. I am able to do it using the update by query plugin.
> 
> Is there a way to do it using Python or Java API client.
> 
> Here is the query that works perfectly fine. Search for a phrase and update a tag.
> 
> curl -XPOST 'localhost:9200/index/type/\_update\_by\_query' -d '{  
> "query" : { "match\_phrase" : { "content" : "michael aronstein" } },  
> "script" : "ctx.\_source.tags += tag",  
> "params" : {  
> "tag" : "ABC"  
> }  
> }'
> 
> ## Amay
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b755711b-16e8-41e1-98b6-38f16b8b2031%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b755711b-16e8-41e1-98b6-38f16b8b2031%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/A838211A-5B81-427F-8C99-5B1087B714F2%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/A838211A-5B81-427F-8C99-5B1087B714F2%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 12:34am UTC](https://discuss.elastic.co/t/update-by-query-python-java-client/22051/3 "2017-07-06T00:34:01Z")

</div>


