Elastic Search Query: (A or B) and (C or D)
You can use bool
and terms
query to do this like below:
{ "query": { "bool": { "must": [ { "terms": { "Country": [ "USA", "UK" ] } }, { "terms": { "Expertise": [ "Botany", "Physics" ] } } ] } }}
On the other hand you can only use bool
query to do this:
{ "query": { "bool": { "must": [ { "bool": { "should": [ { "term": { "Country": { "value": "USA" } } }, { "term": { "Country": { "value": "UK" } } } ] } }, { "bool": { "should": [ { "term": { "Expertise": { "value": "Botany" } } }, { "term": { "Expertise": { "value": "Physics" } } } ] } } ] } }}
But, please look documentation before asking any other question. Maybe, you may find a shorter query.