从Elasticsearch导入Elasticsearch和助手
从ElasticSearch导入ElasticSearch,帮助程序
es =ElasticSearch()
运行上述代码时遇到以下错误:
ValueError Traceback (most recent call last)
Input In [15], in <cell line: 6>()
1 #Import Elascticsearch and helpers from elasticsearch
3 from elasticsearch import Elasticsearch, helpers
----> 6 es = Elasticsearch()
File /opt/homebrew/anaconda3/lib/python3.9/site-packages/elasticsearch/_sync/client/__init__.py:191, in Elasticsearch.__init__(self, hosts, cloud_id, api_key, basic_auth, bearer_auth, opaque_id, headers, connections_per_node, http_compress, verify_certs, ca_certs, client_cert, client_key, ssl_assert_hostname, ssl_assert_fingerprint, ssl_version, ssl_context, ssl_show_warn, transport_class, request_timeout, node_class, node_pool_class, randomize_nodes_in_pool, node_selector_class, dead_node_backoff_factor, max_dead_node_backoff, serializer, serializers, default_mimetype, max_retries, retry_on_status, retry_on_timeout, sniff_on_start, sniff_before_requests, sniff_on_node_failure, sniff_timeout, min_delay_between_sniffing, sniffed_node_callback, meta_header, timeout, randomize_hosts, host_info_callback, sniffer_timeout, sniff_on_connection_fail, http_auth, maxsize, _transport)
128 def __init__(
129 self,
130 hosts: t.Optional[_TYPE_HOSTS] = None,
(...)
188 _transport: t.Optional[Transport] = None,
189 ) -> None:
190 if hosts is None and cloud_id is None and _transport is None:
--> 191 raise ValueError("Either 'hosts' or 'cloud_id' must be specified")
193 if timeout is not DEFAULT:
194 if request_timeout is not DEFAULT:
ValueError: Either 'hosts' or 'cloud_id' must be specified
弹性服务器已启动并运行,可以托管。无法执行现有脚本
1条答案
按热度按时间axr492tv1#
请参阅https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/connecting.html。您需要使用类似以下的内容;