我在建立干草堆/django/elasticsearch时有两个问题
这些文档并没有说明这些情况有什么特别之处,我的设置是根据干草堆文档,我遗漏了什么?
我的索引:
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,
},
}发布于 2014-10-02 03:09:18
1)如果use_template=True只索引您在template文件中所放的内容,那么将您想要索引的所有字段放在那里。2)添加INCLUDE_SPELLING后是否刷新索引?
发布于 2016-02-22 14:26:03
确保启用了拼写检查组件。
要做的第一件事是在SearchIndex类上创建一个特殊字段,该字段反映文本字段,但使用FacetCharField。这将禁用Solr所做的后处理,这可能会搞乱您的建议。建议如下:
class MySearchIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
# ... normal fields then...
suggestions = indexes.FacetCharField()
def prepare(self, obj):
prepared_data = super(MySearchIndex, self).prepare(obj)
prepared_data['suggestions'] = prepared_data['text']
return prepared_data一旦完成,spelling_suggestions方法应该返回适当的值。
https://stackoverflow.com/questions/26144555
复制相似问题