私はDjango-HaystackとWhooshをインストールして、乾草のマニュアルに従って設定しましたが、何を検索しても「結果は見つかりません」と表示されます。インデックスが明らかにOKであるにもかかわらず、検索ページに表示されます。Haystack with Whoosh結果が返ってこない
"manage.py rebuild_index" を実行している場合、それは正確に述べて:
Indexing 12 assets
indexed 1 - 12 of 12 (worker PID: 1234).
とDjangoのシェルでこれを実行している:
from whoosh.index import open_dir
ix = open_dir('mysite/whoosh_index')
from pprint import pprint
pprint(list(ix.searcher().documents()))
それは正しく12のインデックス付きの資産のすべての詳細を返し、だから、インデックスがうまくいくように見えますが、何を検索しても結果は得られません。「結果が見つかりません」だけです!
私はStackOverflow(とGoogleにポップアップされた他のすべての場所)の他の同様の質問では役に立たないとアドバイスを続けてきました。
誰にも提案はありますか?
ファイルの使用(簡潔にするために編集):
settings.py
INSTALLED_APPS = [
....
'haystack',
'assetregister',
....
]
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}
models.py
class Asset(models.Model):
asset_id = models.AutoField(primary_key=True)
asset_description = models.CharField(max_length=200)
asset_details = models.TextField(blank=True)
search_indexes.py
from haystack import indexes
from .models import Asset
class AssetIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
asset_description = indexes.CharField(model_attr='asset_description')
def get_model(self):
return Asset
def no_query_found(self):
# The .exclude is a hack from another stackoverflow question that prevents it returning an empty queryset
return self.searchqueryset.exclude(content='foo')
def index_queryset(self, using=None):
return self.get_model().objects
/テンプレート/検索/ indexes/assetregister/
Django==1.9.3
django-cleanup==0.4.2
django-haystack==2.5.0
django-pyodbc-azure==1.9.3.0
Pillow==3.2.0
pyodbc==3.0.10
Whoosh==2.7.4
私はこれを試しました。最初、haystackbrowserはDjango1.10との互換性の問題を抱えていました。私は、アプリケーションをフォークし、互換性の問題を修正し、それを実行します。管理パネルで索引付けされたすべての項目を表示します。私はサーバーを再起動することができないので、おそらくそれが理由ですが、私はまだこのアプリケーションをインストールした後に何の結果も得られません。 –