Multiple values match query in Update by query

Hi All,

I have to update one field based on match of multiple values of a field.I want to update field amt as 9000 based on query of multiple values of RRN but multiple values are not supported and giving error.

Is there any alternate solution to this.Thanks in advance

 "type": "illegal_state_exception",
	"reason": "Can't get text on a START_ARRAY at 1:26"

POST testimp/_update_by_query
{
  "script": {
	"source": "ctx._source.amt = 9000",
	"lang": "painless"
  },
  "query": {
	"match": {
	  "RRN" : [3201,1209]
	}
  }
}

Hi @sarvendras ,

you should be able to use a bool query like:

"query": {
  "bool" : {
    "must" : [{
      "match": {
        "RRN" : 3201
      },
      "match": {
        "RRN" : 1209
      }
    }]
  }
}

giving you AND semantics between the two values. You can replace must with should to get OR semantics.

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.