4


私はHaystackv1.0とWhooshv1.8.1を使用して、自分のWebサイト用にカスタマイズされた検索エンジンを構築しています。すべてがうまく機能しますが、問題は、インデックス付きモデルの多くのエントリで結果が得られないことです。

たとえば、私には4つの登録モデルがあります-メンバー、ゲスト、イベント、スポンサー。djangoシェルからインデックスを再構築すると、次のようになります。

./manage.pyrebuild_index

Indexing 26 members.  
Indexing 3 events.
Indexing <x> guests.  
Indexing <y> sponsors.  

しかし、SearchQuery APIコマンドを実行したり、検索ページを検索したりすると、メンバー名の半分を検索できません。私が理解できないのは、14〜15人のメンバーを検索できるのに、残りのメンバーを検索できないということです。メンバーの半分が正しくインデックス付けされているので、私のテンプレート*_text.txt*ファイルは正しいはずです。

これを試すことができ
ますhttp://www.edciitr.com/search/?q=xx
= Vikeshは1つの結果を返します(予想どおり)x
= Akshitは結果を返しません(問題!)

「Akshit」と「Vikesh」の両方の値は、rebuild_indexの前に存在していました。これが私が検索しようとしている26人のメンバー全員のリストです-http://www.edciitr.com/contact/

4

2 に答える 2

3

さて、問題が Whoosh にあるのか Haystack にあるのかを調べるために私が行ったことは次のとおりです。django シェルを開き、haystack SearchQuery API 検索に表示されなかった用語を検索しました。

./manage.py shell   
$>> import whoosh 
$>> from whoosh.query import *  
$>> from whoosh.index import open_dir
$>> ix = open_dir('/home/somedir/my_project/haystack/whoosh/')  
$>> ix.schema  
<Schema: ['branch', 'category', 'coordinator', 'date_event', 'designation','details', 'django_ct', 'django_id'> 'name', 'organisation', 'overview','text', 'title']>
$>> searcher = ix.searcher()  
$>> res = searcher.search(Term('text',u'akshit'))  
$>> print res  
<Top 1 Results for Term('text', 'akshit') runtime=0.000741004943848>
$>> print res['0']['name']  
u'Akshit Khurana'   

ご覧のとおり、Whoosh はすべてのデータを正しくインデックス付けしています。だから、今私は SearchQuery API を試します

./manage.py shell
 $>> from haystack.query import SearchQuerySet
 $>> sqs = SearchQuerySet().filter(content='akshit')
 $>> sqs
 $>> []

そのため、haystack ライブラリーの whoosh_backend.py ファイルを調べて、何が起こっているのかを確認する必要があることに気付きました。開ける -haystack.backends.whoosh_backend around line number 345

'''Uncomment these two lines because the raw_results set becomes empty after the filter     call for some queries''  
if narrowed_results:
      raw_results.filter(narrowed_results)

#if narrowed_results:
      #raw_results.filter(narrowed_results)

そして、それは機能します。SearchQueryAPI は、期待どおりにテスト クエリの結果を 1 つだけ返します。ウェブ検索は機能していますが、ここで干し草の山の問題を知りたいです。

于 2011-04-05T07:11:28.957 に答える