I'm trying to use Haystack with Whoosh to index and search in my app. When I'm rebuilding the index I'm getting this results:
All documents removed. Updating backend: default default: Backend doesn't require rebuild. Skipping
this is my SearchIndex Class:
class BlogIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True, template_name="snip_text.txt")
headline = indexes.CharField(model_attr="headline", null=True)
body = indexes.CharField(model_attr="body")
def get_model(self):
return Snip
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(date__lte=timezone.now())
This is my blog_text.txt file (which located in templates/search/indexes/myapp/):
{{ object.headline }}
{{ object.body }}
I added haystack to INSTALLED_APPS and its configuration in the settings file. My DB is sqlite (just for development...).
What am I doing wrong?
Thanks!
R
UPDATE
Create a management command like this (name the file as you wish - e.g my_update_index.py)
from haystack.management.commands import update_index
class Command(update_index.Command):
pass
Do the same for the clear_index command.
the rebuild_index command calls clear_index and the update_index, therefore even if you'll create a new rebuild command it won't work (cause it's looking for the wrong commands).
Just run both commands when you want to rebuild the index, otherwise run your update_index command.
One more note: the name of the folder of the template txt file has to be exactly the same as the model you're trying to index (and it's doesn't matter where in the Index Class you wrote apparently...).
And of course, credit to @solarissmoke