# Match query on array field

**URL:** https://discuss.elastic.co/t/match-query-on-array-field/147933
**Category:** Elasticsearch
**Created:** [September 10, 2018, 9:58am UTC](https://discuss.elastic.co/t/match-query-on-array-field/147933 "2018-09-10T09:58:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Cosmin\_Marginean1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cosmin_marginean1/32/75703_2.png) [@Cosmin\_Marginean1](https://discuss.elastic.co/u/Cosmin_Marginean1)
#### Post date: [September 10, 2018, 9:58am UTC](https://discuss.elastic.co/t/match-query-on-array-field/147933/1 "2018-09-10T09:58:17Z")

</div>

We have a standard match query

```
{
    "query": {
        "match" : {
            "names" : "John smith"
            "operator": "and"
        }
    }
}

```

The field `names` is an array that contains, for a document, values like:

`"name": ["J Smith", "John S"]`

Our use case is that we  
a) want to keep this as an array (we don't know how many names we have)  
b) we only want a doc to be a match if an _array element_ (as opposed to the entire array) contains all the words in the search query. (i.e. the example document above _shouldn't_ be returned)

This doesn't seem possible with an array field because the above doc is a match, probably due to the fact that the combined values of the array do contain all the words.

Any suggestions or ideas are welcome.

Thanks  
Cos

---

<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: [October 8, 2018, 9:58am UTC](https://discuss.elastic.co/t/match-query-on-array-field/147933/2 "2018-10-08T09:58:19Z")

</div>

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