2

I have a following query and I want to change that query into PyES:

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

I have searched in PyES documentation about this "facet_filter" but couldn't come up with good query in PyES.
So need some help for converting this JSON query into PyES format.

suraz
  • 105
  • 1
  • 1
  • 11

1 Answers1

0

This should work. But its untested. I use it similar in another code.

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)    
Julian Hille
  • 669
  • 5
  • 11