I forked tow (Toby White, gratitude for his great work) sunburnt repository from github because I needed range facet funcionality and the workaround (with the filter queries) wasn’t quite what I wanted.
You can checkout here: https://github.com/charlesnagy/sunburnt
Docs about it:
Range facets
More about range facets see: http://wiki.apache.org/solr/SimpleFacetParameters#Facet_by_Range
Now sunburnt support range facets as well. Every range field can be set separately in order to fulfill the requirements. The facet_ranger.update() method takes a dictionary with the field names and the essential parameters (start, end and gap).
Simple usage
1234567 from sunburnt import SolrInterfacesi = SolrInterface('http://some.url:8983/solr/')si.query('Query')si.facet_ranger.update({'price':{'range.start': 1, 'range.end': 99999, 'range.gap': 5000}})
Full example
1234567891011 from sunburnt import SolrInterfacesi = SolrInterface('http://some.url:8983/solr/')query = si.query('Query')query.facet_ranger.update({'price':{'range.start': 1, 'range.end': 99999, 'range.gap': 5000},'weight':{'range.start': 20, 'range.end': 120: 'range.gap': 2}}, mincount=1, limit=10, sort='index')resp = query[:10]resp.facet_counts.facet_ranges
Comments and ideas are welcomed.
Recent comments