How to update documents based on query?


#1

Hi,

I'm stuck at following

I need to run partial update on documents, which would match following query:

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"field1": "test"
}
},
{
"missing": {
"field": "field2"
}
}
]
}
}
}
}
}

I could write java program, which would first retrieve this documents, and run another query to update the field in them.

in sql it would
update table
set field='updated'
where field1 = 'value' and field2 is null;

Is there any simpler way to do it?


(Maarten Roosendaal) #2

Hi,

There's some good documentation out there, this one should help:
https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html

Cheers,
Maarten


(system) #3