When I try to use facets with my filtered search I don't get facets.
Remove the "filtered" element and it works.
Without filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}
}'
This returns my facets as expected:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "encore_dev_product",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "restaurant",
"count" : 1
}, {
"term" : "food",
"count" : 1
}, {
"term" : "entertainment",
"count" : 1
}, {
"term" : "concert",
"count" : 1
} ]
}
}
With filtered:
curl -X GET "http://localhost:9200/products/product/_search?
pretty=true" -d '{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "*",
"default_operator": "AND"
}
}]
},
"filtered": {
"filter": [{
"geo_distance": {
"location_coordinates": "33.6147846,-117.637617",
"distance": "90mi"
}
}]
}
},
"facets": {
"tags": {
"terms": {
"field": "tag_names",
"size": 10,
"all_terms": false
}
}
}
}'
Returns no facets...
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "products",
"_type" : "product",
"_id" : "1",
"_score" : 1.0, "_source" : {"client_id":
1,"description":"","name":"Green Day concert
tickets","location_coordinates":["32.716254,-117.160118"],"tag_names":
["concert","entertainment"]}
}, {
"_index" : "products",
"_type" : "product",
"_id" : "2",
"_score" : 1.0, "_source" : {"client_id":
1,"description":null,"name":"Gift certificate","location_coordinates":
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag_names":
["food","restaurant"]}
} ]
}
What am I doing wrong?