Elastisearch-获取聚合中未找到的存储桶

时间:2018-07-25 10:26:25

标签: elasticsearch

我正在使用不同的聚合过滤器进行搜索。如下图所示: without clicked with a selected checkbox

当用户选中一个复选框时,我会启动查询并过滤整个data_set,我希望聚合导致未找到的聚合。

就像我能够在过滤器上显示

  1. 图片1:项目数量1
  2. Picture2 projet消失

但是我希望能够从我的elastisearch查询中获得总计为0的匹配项

如果需要,我可以粘贴我的elasticsearch查询。

我需要查阅ES文档中有关关键字的任何帮助,或者这样做的窍门,对我来说都是新的呼吸。

谢谢

elasticsearch:6.3

更新

查询ES

 "query": {
            "bool": {
                "must": [],
                "filter": {
                    "bool": {
                        "must": [],
                        "should": []
                    }
                }
            }
        },
        "highlight": {
            "fields": {
                "numberStr": { "type": "plain" },
                "natureOfRequest": { "type": "plain" }
            }
        },
        'aggs': {
            'all_aggs': {
                'global': {},
                "aggs": {
                    "orderType": {
                        "filter": {
                            "bool": {
                                "must": [],
                                "should": []
                            }
                        },
                        "aggregations": {
                            "filtered_orderType": {
                                "terms": { "field": "orderType.keyword" }
                            }
                        }
                    },
                    'site': {
                        "filter": {
                            "bool": {
                                "must": [],
                                "should": []
                            }
                        },
                        "aggregations": {
                            "filtered_site": {
                                "terms": { "field": "site.name.keyword" },
                                "aggs": {
                                    "data": {
                                        "top_hits": {
                                            "_source": {
                                                "includes": ["site.name", "site._id"]
                                            },
                                            "size": 1
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

0 个答案:

没有答案
相关问题