New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logic to implement Interval Faceting (Solr only). #1510

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@stmos

stmos commented May 23, 2017

This currently only works with Solr backend (>4.10).

More details about interval faceting can be found at: Solr - Interval Faceting

Example:
intervals = ['[0,100]', '(100, *]']
sqs = SearchQuerySet()
sqs.interval_facet('price', intervals=intervals)

Key replacement is supported as well:
sqs.interval_facet('price', intervals=['{!key=cheap}[0, 100]', '{!key=expensive}[100, *)']).facet_counts()

Output:
{u'dates': {}, u'fields': {}, u'intervals': {'price': {u'cheap': 4, u'expensive': 47}}, u'queries': {}}

Syntax is explained at the URL posted above.
There is no need to specify the "facet=true" when defining the search index for the fields you want to use for interval faceting.

Only requirement is that fields used for Interval Faceting must have “docValues” enabled (not required for Solr 5.20 and above)

@stmos stmos changed the title from Added logic to implement interval faceting. This only works with Solr… to Added logic to implement Interval Faceting (Solr only). May 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment