haystack elasticsearch RealtimeSignalProcessor updates only “default” connection

﹥>﹥吖頭↗ 提交于 2019-12-24 14:43:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/33001176/haystack-elasticsearch-realtimesignalprocessor-updates-only-default-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!