0

I want to know if there is a way to update elasticsearch documents after filtering them out.

Let's say I have a user collection with following documents:

[
  { "name":"u1","age":23},
  { "name":"u2","age":31},
  { "name":"u3","age":27},
  { "name":"u4","age":33}
]

Now what I need to do is update the names of all the users who have ages above 30. Looking at a lot of documentation and searching for hours on google, including the following document http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/_updating_documents.html

I couldn't find a way to do it. So if we look into the docs, we are providing the id of the document, so it doesn't suite my need. Is there a way to do this sort do this sort of stuff in Elasticsearch?

Community
  • 1
  • 1
Sambhav Sharma
  • 5,741
  • 9
  • 53
  • 95

1 Answers1

2

From the link you provided:

Note that as of this writing, updates can only be performed on a single document at a time. In the future, Elasticsearch will provide the ability to update multiple documents given a query condition (like an SQL UPDATE-WHERE statement).

So, this is not supported at the moment. But you can consider taking a look at this plugin: https://github.com/yakaz/elasticsearch-action-updatebyquery/.

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89