Terms query from array with AND


(Isaac Perez Moncho) #1

Hi,

what would be the best way to make the below terms query to AND the two fields in the array passed to the .raw field?
At the moment if seems to be doing an OR between them:

{"sort" : [{ "_score" : {"order" : "asc"}}],"query": {"bool" : {"filter" :{"bool": {"must":[{ "terms": {"categories.raw" : ["category2","category1"]}}, {"range": {"price": {"gte": 0,"lte": 250}}}]}}}},"from": 0, "size": 40}

Thanks,
Isaac


(Isaac Perez Moncho) #3

Are you sure it will make the terms query AND instead of the default OR?


(drjz) #4

My apologies, misread your question. Can you post an example of a document?


(Isaac Perez Moncho) #5

sure,

{
"name" : "name_of_the_thing",
"categories" : ["category1","category2"],
"price": 10
}

Thanks
Isaac


(system) #6

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