I am trying to integrate search with django-haystack,
Although it works well with the sample backend, when replacing the backend with whoosh, it always returns 0 results.
settings.py:
HAYSTACK_DEFAULT_OPERATOR = 'AND' HAYSTACK_SITECONF = 'search_sites' HAYSTACK_SEARCH_ENGINE = 'whoosh' HAYSTACK_SEARCH_RESULTS_PER_PAGE = 20 HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_ROOT, 'search_index')
search_sites.py
import haystack haystack.autodiscover()
profiles / search_indexes.py:
from haystack import indexes from haystack import site from profiles.models import Profile class ProfileIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) def index_queryset(self): """Used when the entire index for model is updated.""" return Profile.objects.all() site.register(Profile, ProfileIndex)
templates / search / indexes / profiles / profile_text.txt:
{{ profile.name }} {{ profile.description }}
Running python manage.py rebuild_index returns:
All documents removed. Indexing 60 profiles.
When launched in the command shell:
>>> from haystack.query import SearchQuerySet >>> sqs = SearchQuerySet().all() >>> sqs.count() 0
When switching whoosh using the "simple" backend, everything works fine and 60 results are returned.
Everything seems to be configured correctly, according to Getting Started with Haystack and Debugging Haystack .
I tried installing the previous version of Whoosh without any success.
Feeling very stupid at this moment, any help would be truly appreciated.
Package Versions:
python==2.7 Django==1.3.1 Whoosh==2.3.2 django-haystack==1.2.6
Update:
- Canceling Whoosh before 1.8.4 did not help.
- When using the basic search pattern described in the Haystack Tutorial , all results are returned for 1-letter queries and 0 results for other searches.