gpt4 book ai didi

django - 使用Haystack设置Elasticsearch

转载 作者:行者123 更新时间:2023-12-02 22:47:19 25 4
gpt4 key购买 nike

我曾经使用Whoosh作为搜索后端,但是现在我切换到elasticsearch并尝试使事情正常进行。

尝试重建索引时出现错误:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /_bulk?op_type=create (Caused by <class 'socket.error'>: [Errno 61] Connection refused)

以下是我的settings.py中的内容:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://localhost:8000/',
'INDEX_NAME': 'haystack',
},
}

我的问题是,URL的用途是什么?我正在本地运行以进行开发,并且已部署在Heroku上。

最佳答案

端口应为9200。

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}

另外,您必须确保使用的是haystack的开发版本(2.0)。

编辑:

您可能想通过执行以下命令首先确保ElasticSearch正在运行:
curl -XGET 'http://127.0.0.1:9200/my_index/_mapping?pretty=1'

关于django - 使用Haystack设置Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15692512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com