How to do faceting with sub-facet and aggregate functions using PySolr

177 Views Asked by At

I have a facet query working with count but I would like to do a sum on a field on the data already grouped by the facet.field. I have the json facet query working in the browser but no luck with PySolr.

import pysolr
import pprint

conn = pysolr.Solr('http://localhost:8080/solr/corename')
result = conn.search('*:*', **{
    'facet': 'true',
    'facet.type': 'terms',
    'facet.limit': 5,
    'facet.field': 'field_name',
    'f.results.facet.sum': '{!func}sum(daily_amount)'
})   

pprint.pprint(result.facets)

I would like to do a sum on a particualr field, is that possible in PySolr?

0

There are 0 best solutions below