【发布时间】:2014-01-09 05:39:40
【问题描述】:
我有一个基于 django 的应用程序,带有 haystack 和 whoosh 搜索引擎。我想提供与重音和特殊字符无关的搜索,以便我也可以通过使用不带特殊字符的单词来查找带有特殊字符的索引数据:
索引为:
'café'
搜索词:
'cafe'
'café'
我已经编写了一个特定的 FoldingWhooshSearchBackend,它使用 StemmingAnalyzer 和 aCharsetFilter(accent_map),如以下文档中所述:
https://gist.github.com/gregplaysguitar/1727204
但是搜索仍然无法正常工作,即我无法使用“cafe”进行搜索并找到“café”。我使用以下方法查看了搜索索引:
from whoosh.index import open_dir
ix = open_dir('myservice/settings/whoosh_index')
searcher = ix.searcher()
for doc in searcher.documents():
print doc
特殊字符仍在索引中。
我需要做一些额外的事情吗?是关于更改索引模板的吗?
【问题讨论】:
-
仅供参考,我更新了这个要点,它适用于 Haystack 2.4.0 和 Whoosh 2.7.0。我不确定你的问题是什么,但我最初写它的方式相当脆弱,所以也许这就是问题所在。
标签: django search django-haystack whoosh