首页 > 解决方案 > ElasticSearch DSL -> 组合多个过滤器并消除元数据

问题描述

以下查询假设返回 product_id 为 12 的文档。

request = Search(using=client, index='myIndex') \
            .filter("match",product_id=12) \
            .source(myFieldsArray)

现在我还想删除所有parent为空的文档。
我还希望不返回元数据,只返回实际数据(在我filter_path=hits.hits._source.*在查询字符串上使用的 kopf 上)

我如何在弹性搜索 dsl 上执行这些操作?

详细信息:使用 Elasticsearch 2.4

标签: pythonelasticsearchelasticsearch-dsl

解决方案


过滤器可以链接,就在.filter(外面。为了消除元数据,您必须设置params类似.params(filter_path="hits.hits._source.*")


推荐阅读