# Update multiple docs based on a query

**URL:** https://discuss.elastic.co/t/update-multiple-docs-based-on-a-query/8129
**Category:** Elasticsearch
**Created:** [June 16, 2012, 9:03am UTC](https://discuss.elastic.co/t/update-multiple-docs-based-on-a-query/8129 "2012-06-16T09:03:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![feridcelik](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@feridcelik](https://discuss.elastic.co/u/feridcelik)
#### Post date: [June 16, 2012, 9:03am UTC](https://discuss.elastic.co/t/update-multiple-docs-based-on-a-query/8129/1 "2012-06-16T09:03:34Z")

</div>

Hey all,

Is it possible to update documents based on a query, simialar to mongodb update query.  
I mean, smt like:  
{  
query: {  
bool: {  
must: [  
{  
term: {  
text: "apple"  
}  
}  
]  
}  
},  
update:{  
set: {  
tag : "fruit"  
}  
}  
}  
I can query first, than update each doc with its id, but it takes too long. There should be a better solution.

Thanks.

---

<div class="post-metadata">

### Author: ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)
#### Post date: [June 16, 2012, 9:13am UTC](https://discuss.elastic.co/t/update-multiple-docs-based-on-a-query/8129/2 "2012-06-16T09:13:57Z")

</div>

Update by query is not implemented yet but there is an opened issue  
for it [Update API: update by query · Issue #1607 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1607)

On Sat, Jun 16, 2012 at 11:03 AM, feridcelik [feridcelik@gmail.com](mailto:feridcelik@gmail.com) wrote:

> Hey all,
> 
> Is it possible to update documents based on a query, simialar to mongodb  
> update query.  
> I mean, smt like:  
> {  
> query: {  
> bool: {  
> must: [  
> {  
> term: {  
> text: "apple"  
> }  
> }  
> ]  
> }  
> },  
> update:{  
> set: {  
> tag : "fruit"  
> }  
> }  
> }  
> I can query first, than update each doc with its id, but it takes too long.  
> There should be a better solution.
> 
> Thanks.
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Update-multiple-docs-based-on-a-query-tp4019410.html](http://elasticsearch-users.115913.n3.nabble.com/Update-multiple-docs-based-on-a-query-tp4019410.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
Benjamin DEVEZE

---

<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, 3:23am UTC](https://discuss.elastic.co/t/update-multiple-docs-based-on-a-query/8129/3 "2017-07-06T03:23:44Z")

</div>


