【发布时间】:2014-11-26 11:33:58
【问题描述】:
我在设置 haystack/django/elasticsearch 时遇到了两个问题
我从来没有从索引字段中得到结果,例如index.CharField(model_attr='title') 没有得到我的结果。仅当我将 {{ object.title }} 放入我的 txt 模板中时,我才能获得匹配标题的结果
如果我的标题是“foo”,我永远不会得到“fo”的结果,而我的后端设置中确实将 INCLUDE_SPELLING 设置设置为 True。
文档没有说明这些情况的任何特别之处,我的设置是根据 haystack 文档,我缺少什么?
我的索引:
class FooIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title') # never gets me results unless I add it to the template
def get_model(self):
return Foo
我的设置:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
'INCLUDE_SPELLING': True,
},
}
【问题讨论】:
标签: django elasticsearch django-haystack