[Django]-How to filter results using django-haystack SearchQuerySet?

3👍

After some digging, I updated my index class to look like this:

class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.NgramField(document=True, use_template=True)
    title = indexes.NgramField(model_attr='title')

    abstract = indexes.NgramField(model_attr='abstract')

    def get_model(self):
        return Article

    def index_queryset(self, using=None):
        return self.get_model().objects.all()

There’s something wrong with using .filter() on attributes of type indexes.CharField in django-haystack 2.1.0. Maybe somebody can provide more detail, but this is what works for me.

Leave a comment