# Updating many documents at once

**URL:** https://discuss.elastic.co/t/updating-many-documents-at-once/3899
**Category:** Elasticsearch
**Created:** [February 8, 2011, 3:21pm UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899 "2011-02-08T15:21:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)
#### Post date: [February 8, 2011, 3:21pm UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899/1 "2011-02-08T15:21:53Z")

</div>

Hello

I'd like to modify many documents in ES at once (something similar to  
sql update). To achieve this functionality now I have to get all  
matching documents from ES, modify them and index again.  
Is there a possibility in ES to modify many documents at once in  
better and faster way?  
Meybe there should be a command that takes query/filter and function  
(for example in java script) that modifies source of all matching  
documents.  
What do you think about it? Is it possible to implement?

Regards  
Wojciech Durczyński

---

<div class="post-metadata">

### Author: ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)
#### Post date: [February 8, 2011, 8:23pm UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899/2 "2011-02-08T20:23:58Z")

</div>

do you mean something like bulk updating?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

also possible via java api:

BulkRequestBuilder brb = client.prepareBulk();  
for (Entry\<String, XContentBuilder\> e : docs.entrySet()) {

brb.add(Requests.indexRequest(indexName).type(indexType).id(e.getKey()).source(e.getValue()));  
brb.setRefresh(true);  
}  
if (brb.numberOfActions() \> 0)  
brb.execute().actionGet();

On 8 Feb., 16:21, Wojciech Durczyński  
[wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com) wrote:

> Hello
> 
> I'd like to modify many documents in ES at once (something similar to  
> sql update). To achieve this functionality now I have to get all  
> matching documents from ES, modify them and index again.  
> Is there a possibility in ES to modify many documents at once in  
> better and faster way?  
> Meybe there should be a command that takes query/filter and function  
> (for example in java script) that modifies source of all matching  
> documents.  
> What do you think about it? Is it possible to implement?
> 
> Regards  
> Wojciech Durczyński

---

<div class="post-metadata">

### Author: ![Enrique\_Medina\_Monte](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Enrique\_Medina\_Monte](https://discuss.elastic.co/u/Enrique_Medina_Monte)
#### Post date: [February 8, 2011, 8:53pm UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899/3 "2011-02-08T20:53:05Z")

</div>

Scrolling can maybe also help here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

2011/2/8 Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)

> do you mean something like bulk updating?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)
> 
> also possible via java api:
> 
> BulkRequestBuilder brb = client.prepareBulk();  
> for (Entry\<String, XContentBuilder\> e : docs.entrySet()) {
> 
> brb.add(Requests.indexRequest(indexName).type(indexType).id(e.getKey()).source(e.getValue()));  
> brb.setRefresh(true);  
> }  
> if (brb.numberOfActions() \> 0)  
> brb.execute().actionGet();
> 
> On 8 Feb., 16:21, Wojciech Durczyński  
> [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com) wrote:
> 
> > Hello
> > 
> > I'd like to modify many documents in ES at once (something similar to  
> > sql update). To achieve this functionality now I have to get all  
> > matching documents from ES, modify them and index again.  
> > Is there a possibility in ES to modify many documents at once in  
> > better and faster way?  
> > Meybe there should be a command that takes query/filter and function  
> > (for example in java script) that modifies source of all matching  
> > documents.  
> > What do you think about it? Is it possible to implement?
> > 
> > Regards  
> > Wojciech Durczyński

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [February 8, 2011, 9:05pm UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899/4 "2011-02-08T21:05:40Z")

</div>

Being able to provide a query and a javascript to munge the docs is certainly something that is on the roadmap. I have talked about it with aparo and he even hacked it a bit to work on his fork.

Still, it required some foundation to be laid down in order to make it work properly. The good news is that most of the work is done with versioning. There is still some work left for replication aspect, but I certainly see such a feature in the near future.

-shay.banon  
On Tuesday, February 8, 2011 at 10:53 PM, Enrique Medina Montenegro wrote:

> Scrolling can maybe also help here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/scroll.html)
> 
> 2011/2/8 Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)
> 
> > do you mean something like bulk updating?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)
> > 
> > also possible via java api:
> > 
> > BulkRequestBuilder brb = client.prepareBulk();  
> > for (Entry\<String, XContentBuilder\> e : docs.entrySet()) {
> > 
> > brb.add(Requests.indexRequest(indexName).type(indexType).id(e.getKey()).source(e.getValue()));  
> > brb.setRefresh(true);  
> > }  
> > if (brb.numberOfActions() \> 0)  
> > brb.execute().actionGet();
> > 
> > On 8 Feb., 16:21, Wojciech DurczyÅski  
> > [wojciech.durczyn...@comarch.com](mailto:wojciech.durczyn...@comarch.com) wrote:
> > 
> > > Hello
> > > 
> > > I'd like to modify many documents in ES at once (something similar to  
> > > sql update). To achieve this functionality now I have to get all  
> > > matching documents from ES, modify them and index again.  
> > > Is there a possibility in ES to modify many documents at once in  
> > > better and faster way?  
> > > Meybe there should be a command that takes query/filter and function  
> > > (for example in java script) that modifies source of all matching  
> > > documents.  
> > > What do you think about it? Is it possible to implement?
> > > 
> > > Regards  
> > > Wojciech DurczyÅski

---

<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, 4:12am UTC](https://discuss.elastic.co/t/updating-many-documents-at-once/3899/5 "2017-07-06T04:12:20Z")

</div>


