Hello,
Below is the gist related to my question.
I have set up a sample index that contains a couple simple documents that contain a nested type. In addition, I have created a facet that only contains those filtered nested items that relate to the nested filter I have applied. So basically everything is working as I would like, except that in addition to the stores.id filter, I would like to query against the name and/or desc field (i.e. name=samsung), which is at the root level. I have tried a number of different attempts at this, but with no luck. In addition to the gist, I have copied one of the documents below, as well as the query I am using as of now, which is working with just the filter.
curl -X POST "http://localhost:9200/deals_near_me/deals" -d '{
"skuid": "123456",
"name": "Samsung 55 inch TV",
"desc": "Samsung Smart HDTV that really looks nice and is super thin",
"price2" : 300,
"stores":
[
{ "id": "1001", "price": 599, "inv_status" : "avail" },
{ "id": "1002", "price": 699, "inv_status" : "avail" },
{ "id": "1003", "price": 799, "inv_status" : "avail" }
]
}'
curl 'localhost:9200/deals_near_me/deals/_search?pretty=1' -d '{
"query": {
"nested": {
"_scope": "my_scope",
"path": "stores",
"score_mode": "avg",
"query": {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"term" : { "stores.id" : "1001" }
}
}
}
}
},
"facets" : {
"range1" : {
"range" : {
"stores.price" : [
{ "to" : 200.0 },
{ "from" : 200.0, "to" : 500.0 },
{ "from" : 500.1, "to" : 700.0 },
{ "from" : 700, "to" : 900.0 },
{ "from" : 900, "to" : 1000.0 },
{ "from" : 1000.0 }
]
},
"scope": "my_scope"
}
}
}'