1

I am using:

django: 1.9.7
django-haystack: 2.5.0
whoosh: 2.7.4

search_index.py

class ProfileIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    last_name= indexes.CharField(model_attr='last_name')
    content_auto = indexes.EdgeNgramField(model_attr='first_name')
    def get_model(self):
        return User
    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()  

user_text.txt

{{ object.last_name }}

in the views.py i try:
SearchQuerySet().count() => returns 0
SearchQuerySet().all() => returns None

I've read about some issues with the latest Whoosh implementation in django-haystack but i'm not sure if the problem is in my code

lcadc17
  • 195
  • 1
  • 16

1 Answers1

0

Please see my answer here:

Django Haystack & Whoosh Search Working, But SearchQuerySet Return 0 Results

There is a bug in Django-Haystack with Woosh that means if you use an Ngram or EdgeNGram field SearchQuerySet().count() and SearchQuerySet().all().count() will always return 0 unless you specify a filter.

e.g.

SearchQuerySet().all().count()
>> 0

SearchQuerySet().all().exclude(content='thisshouldnotmatchanything').count()
>> 14 [the total number of indexed objects]
Community
  • 1
  • 1
TimJ
  • 399
  • 4
  • 18