Search code examples
djangofielddjango-haystackfacet

facet multiple fields on search query set


How can I choose multiple fields for faceting on a SearchQuerySet ? The Example in the Documentation shows fow to facet on a single field.

sqs = SearchQuerySet().facet('author')

Say, I have multiple fields that I want to facet on like , author, location, score ? How would I do that ?

Currently, if I use the above example from the documentation, it works as expected, But how do I implement multiple fields for faceting on a SearchQuerySet ?


Solution

  • You have to call facet method multiple times on the queryset for each field. You can do something like this.

    sqs = SearchQuerySet()
    facet_list = ('author', 'location', 'age')
    for item in facet_list:
        sqs = sqs.facet(item)