2

我有以下查询,我想将该查询更改为 PyES:

{
    "facets": {
        "participating-org.name": {
            "terms": {
                "field": "participating-org.name"
            },
            "facet_filter": {
                "term": {
                    "participating-org.role": "funding"
                }
            },
            "nested": "participating-org"
        }
    }
}

我在 PyES 文档中搜索了有关此“facet_filter”的信息,但无法在 PyES 中找到好的查询。
因此需要一些帮助来将此 JSON 查询转换为 PyES 格式。

4

1 回答 1

0

这应该有效。但它未经测试。我在另一个代码中类似地使用它。

from pyes.facets import FacetFactory, TermFacet, ANDFacetFilter
facet_factory = FacetFactory()
facet_filter = ANDFacetFilter(TermFilter('category'))
term_facet = TermFacet(
            field='attributes',
            facet_filter=facet_filter,
            name='yourfacet',
            size=100,
            )

facet_factory.add(term_facet)    
于 2013-02-14T08:00:40.040 回答