我正在按照haystack http://docs.haystacksearch.org/en/master/tutorial.html#installation和search engine installation https://django-haystack.readthedocs.io/en/master/installing_search_engines.html#elasticsearch的安装说明进行操作
我已经安装了Elasticsearch 5.1.16,它被列为兼容的,并且已经将设置放入,安装指南只有Elasticsearch版本1和2的示例,但声明支持5。
所以我在设置中改成了版本5
'default': {
'ENGINE': 'haystack.backends.elasticsearch5_backend.Elasticsearch5SearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}我还查看了repo,可以看到版本5在其中

但是当我启动我的服务器时,我收到了这个错误:
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'haystack.backends.elasticsearch5_backend'但是当我遍历文件夹结构时,它并没有安装版本5的文件
root@4c1197e002e8:/myapp/# ls /usr/local/lib/python3.6/site-packages/haystack/backends/
__init__.py __pycache__/ elasticsearch2_backend.py elasticsearch_backend.py simple_backend.py solr_backend.py whoosh_backend.py我使用的是与git repo相同的版本,其中包含5后端?
root@4c1197e002e8:/myapp/# pip freeze | grep hay django-haystack==2.8.1
编辑:它也已经安装到我安装的应用程序中了:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'haystack',
...有没有人帮我弄清楚这里少了些什么?谢谢
发布于 2019-10-01 20:08:11
我刚刚做了一个pip install git+https://github.com/django-haystack/django-haystack,现在version5后端就在里面了。
发布于 2020-05-04 09:54:35
我使用的是pipenv:
pipenv install git+https://github.com/django-haystack/django-haystack.git#egg=django-haystackAlexW的答案的一个修改对我起作用了!
发布于 2019-10-01 19:13:01
您需要在已安装的应用程序中添加'haystack‘
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
# Added.
'haystack',
# Then your usual apps...
'blog',]
https://stackoverflow.com/questions/58183444
复制相似问题