问题描述
我有3个搜索索引和3个干草堆连接。我希望实时更新索引,所以我使用RealtimeSignalProcessor。它仅在3个连接中的1个(默认)中工作,但是当我使用其他2个连接搜索术语时,它不起作用。比起我必须手动做python manage.py update_index才能使它工作。如何修复,而不用手动更新索引呢? HAYSTACK_CONNECTIONS = {
'default':{
'ENGINE':'haystack.backends.elasticsearch_backend .ElasticsearchSearchEngine',
'URL':'http://127.0.0.1:9200/',
'INDEX_NAME':'haystack',
},
'autocomplete_tags' :{
'ENGINE':'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL':'http://127.0.0.1:9200/',
'INDEX_NAME':' autcomplete',
'EXCLUDED_INDEXES':['entities.search_indexes.EntityIndex','allauth.search_indexes.UserIndex'],
},
'autocomplete_entities':{
'ENGINE ':'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL':'http://127.0.0.1:9200/',
'INDEX_NAME':'autocomplete_entities',
' EXCLUDED_INDEXES':['tags.search_indexes.TagsIndex',' allauth.search_indexes.UserIndex'],
}
}
HAYSTACK_SIGNAL_PROCESSOR ='haystack.signals.RealtimeSignalProcessor'
答案:
我认为仅使用RealtimeSignalProcessor更新默认连接的原因是INDEX_NAME。在我将所有3个连接INDEX_NAME更改为haystack之后,它的工作原理。
我认为你的弹性搜索方法是不正确的。你通常有一个索引和各种类型。如果你遵循这种方法,所有的类型应该被自动更新(希望)。
干草堆是用Solr构建的,我建议使用Solr。 Haystack建议您想要索引的模型的索引,但实际上是ElasticSearch中的一个类型。看一下你的HAYSTACK_CONNECTIONS,你在一个索引中创建了3个索引,而不是3个索引类型。
我有干草堆与Elasticsearch合作,但是更多的工作要调整它。 / p>
I have 3 search indexes and 3 haystack connections. I want the indexes to be updated in real time so I use RealtimeSignalProcessor. It is working only for 1 of the 3 connections ("default") but it does not work when I search for the term using the other 2 connections. Than I have to do python manage.py update_index manually to make it work.. How can this be fixed without updating the index manually?
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
'autocomplete_tags': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'autcomplete',
'EXCLUDED_INDEXES': ['entities.search_indexes.EntityIndex', 'allauth.search_indexes.UserIndex'],
},
'autocomplete_entities': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'autocomplete_entities',
'EXCLUDED_INDEXES': ['tags.search_indexes.TagsIndex', 'allauth.search_indexes.UserIndex'],
}
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
Answer:
I figured that the reason why only the "default" connection was updated with the RealtimeSignalProcessor is the "INDEX_NAME". After I changed all 3 connection "INDEX_NAME" to "haystack" it works.
I think your approach to elasticsearch is not right. You usually have one index and various types within that. If you follow that approach, all your Types should be automatically updated (hopefully).
Haystack is built with Solr in mind, I would suggest to use Solr. Haystack suggest terms like Index for a model you want to index but its actually a type in ElasticSearch. Looking at your HAYSTACK_CONNECTIONS, you have created 3 indices instead of 3 types within an Index.
I have haystack working with Elasticsearch but it's a lot more work to tune it.
这篇关于干草堆弹性搜索RealtimeSignalProcessor仅更新“默认”连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!