Search code examples
django-haystack

Haystack SearchQuerySet returns None with content filter


I have following SearchIndex:

class ProductIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True)
    display_name = indexes.CharField(model_attr='display_name')
    link = indexes.CharField(model_attr='link')

    def get_model(self):
        return Product

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.\
                    filter(last_updated__lte=datetime.datetime.now())

And it works fine with queries like:

 >>>> SearchQuerySet().filter(display_name='Levis jeans')
 [<SearchResult ... >, <SearchResult ... >, ...]

But when I use any content filter, it returns empty list:

 >>>> SearchQuerySet().filter(content='Levis jeans')
 []

What is wrong?

Also there is no solr Docs with text field.


Solution

  • Solution: set use_template=True for text field. Haystack uses django-templates to render documents for search engine.