Hi
I'm building a Faceted search using ElasticSearch and python (http://elasticsearch-dsl.readthedocs.io/en/latest/). I'm using aggregations for this. Everything is working fine, except one issue: if the user selects an option, this option must stay selected, even if it's filtered out because there are options with a higher count.
I didn't found a way to do this, so I added an extra aggregation which only fetches the selected option:
POST question/question/_search
{
"aggs": {
"_selected_filter_status": {
"aggs": {
"status": {
"terms": {
"field": "status.keyword",
"min_doc_count": 0,
"include": [
"9",
"11"
]
}
}
},
"filter": {
"terms": {
"nonprofit.name.keyword": [
"xxxxx"
]
}
}
}
},
"query": {
"match_all": {}
}
}
The result is:
"aggregations": {
"_selected_filter_status": {
"doc_count": 1,
"status": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "9",
"doc_count": 1
}
]
}
}
}
So as you see there is no bucket for status "11". Any idea why elastic does this, or how I can solve this?
Thanks in advance