Django Haystack+;弹性搜索奇怪的间歇性错误
我在Elasticsearch方面遇到了一个奇怪的问题 一切都很好(索引、查询…),但是有时(我无法确定根本原因),查询索引时出现以下错误:Django Haystack+;弹性搜索奇怪的间歇性错误,django,python-3.x,
elasticsearch,django-haystack,Django,Python 3.x,
elasticsearch,Django Haystack,我在Elasticsearch方面遇到了一个奇怪的问题 一切都很好(索引、查询…),但是有时(我无法确定根本原因),查询索引时出现以下错误: File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner 35. response = get_response(request) File "/usr/local/lib/python3.5/dist-pac
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/home/django/prod/mysite/forum/api.py" in get_topics
66. topics_list = SearchQuerySet().filter(**filter).models(Topic)
File "/usr/local/lib/python3.5/dist-packages/haystack/query.py" in __init__
29. self._determine_backend()
File "/usr/local/lib/python3.5/dist-packages/haystack/query.py" in _determine_backend
55. backend_alias = connection_router.for_read(**hints)
File "/usr/local/lib/python3.5/dist-packages/haystack/utils/loading.py" in for_read
167. return self._for_action('for_read', False, **hints)[0]
Exception Type: IndexError at /forum/api/get-topics/
Exception Value: list index out of range
问题似乎出在\u determine\u后端
功能上
我的后端在Django设置文件中以这种方式配置:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'myindex',
},
}
在我的生产服务器(Python3.5)和开发人员(Python3.6)上也是如此
Haystack版本是:
django-haystack==2.8.1
- Django [required: >=1.11, installed: 2.0.6]
- pytz [required: Any, installed: 2018.4]
elasticsearch==2.4.1
- urllib3 [required: <2.0,>=1.8, installed: 1.23]
django haystack==2.8.1
-Django[必需:>=1.11,已安装:2.0.6]
-pytz[必需:任何,安装:2018.4]
elasticsearch==2.4.1
-urllib3[必需:=1.8,已安装:1.23]
你经历过这样的事情吗
提前谢谢你 你能分享你在ES服务器日志中看到的错误吗?嗯,ES日志中没有具体的内容。事实上,我认为haystack在调用ES之前会失败。您是否设置了自定义的
haystack\u ROUTERS
设置?没有SolaisMoke,没有自定义的haystack\u ROUTERS
:(它应该默认为['haystack.ROUTERS.DefaultRouter']
)。