# Search multiple values against multiple fields

**URL:** <https://discuss.elastic.co/t/search-multiple-values-against-multiple-fields/137980>\
**Category:** Elasticsearch\
**Created:** [June 29, 2018, 1:58pm UTC](https://discuss.elastic.co/t/search-multiple-values-against-multiple-fields/137980 "2018-06-29T13:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reswob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reswob/32/38015_2.png) [@reswob](https://discuss.elastic.co/u/reswob)\
**Post date:** [June 29, 2018, 1:58pm UTC](https://discuss.elastic.co/t/search-multiple-values-against-multiple-fields/137980/1 "2018-06-29T13:58:48Z")

</div>

ES 5.6.3

I've been googling this subject and I've seen some similar discussions, but I have not yet found the exact answer....

I know you can use a terms query to search multiple values against a single field and you can use multi\_match to search a single value against multiple fields, but I have not found a definitive answer if you can search multiple values against multiple fields at once.

psuedo-code:

```
GET index/_search
{
"query": {
"multi_match": {
    "query": {
        "constant_score" : {
            "filter" : {
                "terms" : { "user" : ["john", "jack", "bill"]}
            }
        }
    },
    "fields": [
        "fullname",
        "firstname",
        "username"
    ]
}
}
}

```

The above does not work of course (error: [multi\_match] unknown token [START\_ARRAY] after [query] ).  
Is there a correct way to do this?

If not, and assuming I have a long list of values and a short list of fields, is it faster to go use terms and go through each field or use multi\_match and go through each value?

Thanks.

---

<div class="post-metadata">

**Author:** ![reswob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reswob/32/38015_2.png) [@reswob](https://discuss.elastic.co/u/reswob)\
**Post date:** [June 29, 2018, 2:16pm UTC](https://discuss.elastic.co/t/search-multiple-values-against-multiple-fields/137980/2 "2018-06-29T14:16:16Z")

</div>

Hmm, after some more reading and googling, it looks like the following will work:

```
GET index/_search
{
    "query" : {
        "bool" : {
            "should" : [
                {"terms" : { "user" : ["john", "jack", "bill"]}},
                {"terms" : { "fullname" : ["john", "jack", "bill"]}},
                {"terms" : { "firstname" : ["john", "jack", "bill"]}}
            ]
        }
    }
}
```

---

<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:** [July 27, 2018, 2:16pm UTC](https://discuss.elastic.co/t/search-multiple-values-against-multiple-fields/137980/3 "2018-07-27T14:16:17Z")

</div>

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