python-3.x - Facets 子类型和类型结果未在 Elasticsearch 中一起显示
问题描述
我在 Elasticsearch 中映射了记录,并且 aggs 看起来像这样:
aggregations : {
r_type: {
buckets: [
0: {
key: "test",
doc_count: 57,
r_subtype: {
buckets: [
0: {
key: "y",
doc_count: 5,
label: "TEST",
},
....
...
}
我在搜索结果中同时显示 ar_subtype
和 a时遇到问题。r_type
当我sub_type
从 ar_type
和 another中选择 a 时r_type
,我只看到sub_type
结果。
这是我过滤结果的路径中的代码:
def iter_aggs_options(self, options):
"""Iterate over aggregation options."""
return options.get("aggs", {}).items()
def apply(self, identity, search, params):
"""Evaluate the query str on the search."""
options = self.config.facets_options
# Apply aggregations
for name, agg in self.iter_aggs_options(options):
# `aggs[]=` mutates `self.search`
search.aggs[name] = agg if not callable(agg) else agg()
# Apply post filters
facets_args = params.pop('facets', {})
post_filters = options.get("post_filters", {})
for k in set(facets_args.keys()) & set(post_filters.keys()):
filter_factory = post_filters[k]
values = facets_args[k]
values = values if isinstance(values, list) else [values]
# Execute filter on search
search = search.post_filter(filter_factory(values))
# Set facet values on params (so they are available for links
# generation)
params[k] = values
return search
让我知道我可能缺少什么或问题需要更多信息。
解决方案
推荐阅读
- c# - 如何在 C# 中使用 postgres 将 json 字符串转换为 jsonb 类型
- apache-kafka - 为什么要为 Kafka 使用 AVRO
- r - 如何使用 DPLYR 找到 3 个组之间共享最多的物种
- python - 获取具有加载屏幕的页面的 html
- selenium - 使用 Selenium 获取父元素的更好方法
- spring - 在 Spring 中,如何使用 WebClient 发布到 URL?
- javascript - 在 Javascript 中使用索引数组访问和修改任意深度的嵌套数组
- java - 带有异常抛出构造函数的初始化块
- java - Java正则表达式提取所有内容,但两个括号之间的内容
- php - NGINX 无权访问应用程序文件时的 NGINX 配置,以及 php-fpm 和 docker