0
我跟着草堆教程設立嗖草堆,嗖不是索引任何文件
>>> pip install whoosh
settings.py
import os
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}
,我得到一個空列表
>>> list(ix.searcher().documents())
[]
以下是我的代碼searcher_i ndexes.py
from haystack import indexes
from view_links.models import Projdb
class ProjdbIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title')
author = indexes.CharField(model_attr = 'owner')
# pub_date = indexes.DateTimeField(model_attr='date_start')
def get_model(self):
return Projdb
def index_queryset(self,using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()#filter(pub_date__lte=datetime.datetime.now())
我以前能夠獲得elasticsearch結果,但是當我轉移到嗖我越來越沒有結果。
謝謝你的時間。如果您需要更多信息,請告訴我。
編輯:
我現在得到的結果,這裏是兩件事情我學到。
- 我需要註冊其模型用於索引的應用程序。
- 如果模型的類拼錯在search_indexes.py,運行蟒蛇manage.py rebuild_index沒有拋出任何錯誤,你會得到零個索引對象
我以爲我不需要註冊我正在使用的模型的應用程序。那是我犯的錯誤。 – Ent