How to filter with multiple fields and values in elasticsearch?
Use the following code:
The clause (query) must appear in matching documents and will contribute to the score.
"query": { "bool": { "must" : [ {"term" : { "is_active" : true}}, {"term" : { "gender" : "female"}}, {"term" : { "brand" : "addidas"}}, {"terms": { "categoryId": [1,2,3,4]}} ] }}
Queries specified under the filter element have no effect on scoring
"query": { "bool": { "filter" : [ {"term" : { "is_active" : true}}, {"term" : { "gender" : "female"}}, {"term" : { "brand" : "addidas"}}, {"terms": { "categoryId": [1,2,3,4]}} ] }}