Search multiple values against multiple fields

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.

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

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