I am trying to see if the django-haystack is good for my faceting needs. Currently I want to display number near my facets. Lets say we have a model shown in their docs, but with an extra field for faceting (e.g. style in which author writes notes… e.g. styles are classic or modern). So index will look like this.
class NoteIndex(SearchIndex, indexes.Indexable):
text = CharField(document=True, use_template=True)
author = CharField(model_attr='user', faceted=True)
style = CharField(model_attr='style', faceted=True)
pub_date = DateTimeField(model_attr='pub_date')
Now I make a search query set, and narrowing to facet author e.g. john. Now I want to display estimation on how many products will appear if I will select another author together with John (e.g. +10 articles). Also same question about adding an extra facet from styles… How do I do this. Search BE is elasticsearch.
The facet_counts method of SearchQuerySet does what you want:
Then, you can sum up the number of products by John and the number of products by another author. That will give you the number of products if you were to broaden the search to both of them:
Or, you could even find the author other than John with the most products, and show the number of results if you were to also include that author in the search: