2014-02-18 28 views
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結果,但是當我轉移到嗖我越來越沒有結果。

謝謝你的時間。如果您需要更多信息,請告訴我。

編輯:

我現在得到的結果,這裏是兩件事情我學到。

  1. 我需要註冊其模型用於索引的應用程序。
  2. 如果模型的類拼錯在search_indexes.py,運行蟒蛇manage.py rebuild_index沒有拋出任何錯誤,你會得到零個索引對象

回答

1

你運行命令?

./manage.py rebuild_index 

您是否有任何Projdb記錄?

您在代碼中有這樣的:

text = indexes.CharField(document=True, use_template=True) 

你有沒有建立相應的模板(projdb_text.txt)?

+0

我以爲我不需要註冊我正在使用的模型的應用程序。那是我犯的錯誤。 – Ent

相關問題