# Multiple values match query in Update by query

**URL:** <https://discuss.elastic.co/t/multiple-values-match-query-in-update-by-query/262757>\
**Category:** Elasticsearch\
**Created:** [January 31, 2021, 3:09pm UTC](https://discuss.elastic.co/t/multiple-values-match-query-in-update-by-query/262757 "2021-01-31T15:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarvendras](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarvendras/32/46287_2.png) [@sarvendras](https://discuss.elastic.co/u/sarvendras)\
**Post date:** [January 31, 2021, 3:09pm UTC](https://discuss.elastic.co/t/multiple-values-match-query-in-update-by-query/262757/1 "2021-01-31T15:09:21Z")

</div>

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]
	}
  }
}
```

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [January 31, 2021, 5:16pm UTC](https://discuss.elastic.co/t/multiple-values-match-query-in-update-by-query/262757/2 "2021-01-31T17:16:30Z")

</div>

Hi @sarvendras ,

you should be able to use a bool query like:

```auto
"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.

---

<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:** [February 28, 2021, 5:17pm UTC](https://discuss.elastic.co/t/multiple-values-match-query-in-update-by-query/262757/3 "2021-02-28T17:17:30Z")

</div>

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