Hi Team,
I have basically below documents with multiple collections.
{"id" : 1, "stores" :[1,2,3,4,5], "items":[ 55,44,334,155]}
{"id" : 2, "stores" :[1], "items":[ 55]}
{"id" : 3, "stores" :[1,5], "items":[ 155]}
{"id" : 4, "stores" :[2,3,4,5], "items":[ 55]}
{"id" : 5, "stores" :[1,2,3], "items":[ 55,44,155]}
{"id" : 6, "stores" :[1], "items":[ 55,44,334,155]}
{"id" : 7, "stores" :[1], "items":[ 55]}
{"id" : 8, "stores" :[1,2,3,4,5], "items":[ 55,44,334,55]}
I need a query multiple terms and multiple filter for stores having 1 and items 55 to hold search limiting the exclusive only one store and one item and result should be Id 2 and 7.
I got below query for one element for store but I need to have that to include both stores and items Can any one help on this.
{"query": {"bool" : {"must" : {
"term" : { "stores" : "1" }},"filter" : {"script" : {"script" : {
"inline" : "doc["stores"].length == 1",
"lang" : "painless"}}}}}}
Thanks,