我正在尝试使用Elasticsearch并使用elasticsearch-dsl
Python包为一些Django数据编制索引。在
我已经创建了一个相对基本的测试search.py
,但是当我试图索引任何数据时,会收到一个连接错误。在
from elasticsearch_dsl.connections import connections
from elasticsearch_dsl import Document, Text
from elasticsearch.helpers import bulk
from elasticsearch import Elasticsearch
from . import models
connections.create_connection(hosts=['ELASTICSEARCH_ENDPOINT_URL'],
http_auth='USERNAME:PASSWORD')
class MyIndex(Document):
title = Text()
description = Text()
class Index:
name = 'my-index'
def bulk_indexing():
MyIndex.init()
es = Elasticsearch()
bulk(client=es, actions=(a.indexing() for a in models.MyModel.objects.all().iterator()))
当我运行bulk_indexing()
时,我得到以下错误:
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x1282266d8>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x1282266d8>: Failed to establish a new connection: [Errno 61] Connection refused)
我怀疑语法错误,或者我在创建连接时丢失了一些凭据,但是我找不到任何进一步的信息。在
我使用的是elasticsearchv7.4.0,使用的是弹性云。当我通过浏览器访问URL时,我可以连接。在
为什么不简单地使用您的云ID(您可以在escloud控制台中找到它)?在
相关问题 更多 >
编程相关推荐