class Elasticsearch(BaseClient):
"""
Elasticsearch low-level client. Provides a straightforward mapping from
Python to Elasticsearch REST APIs.
The client instance has additional attributes to update APIs in different
namespaces such as ``async_search``, ``indices``, ``security``, and more:
.. code-block:: python
client = Elasticsearch("http://localhost:9200")
# Get Document API
client.get(index="*", id="1")
# Get Index API
client.indices.get(index="*")
Transport options can be set on the client constructor or using
the :meth:`~elasticsearch.Elasticsearch.options` method:
.. code-block:: python
# Set 'api_key' on the constructor
client = Elasticsearch(
"http://localhost:9200",
api_key="api_key",
)
client.search(...)
# Set 'api_key' per request
client.options(api_key="api_key").search(...)
"""
def __init__(
self,
hosts: t.Optional[_TYPE_HOSTS] = None,
*,
# API
cloud_id: t.Optional[str] = None,
api_key: t.Optional[t.Union[str, t.Tuple[str, str]]] = None,
basic_auth: t.Optional[t.Union[str, t.Tuple[str, str]]] = None,
bearer_auth: t.Optional[str] = None,
opaque_id: t.Optional[str] = None,
# Node
headers: t.Union[DefaultType, t.Mapping[str, str]] = DEFAULT,
connections_per_node: t.Union[DefaultType, int] = DEFAULT,
http_compress: t.Union[DefaultType, bool] = DEFAULT,
verify_certs: t.Union[DefaultType, bool] = DEFAULT,
ca_certs: t.Union[DefaultType, str] = DEFAULT,
client_cert: t.Union[DefaultType, str] = DEFAULT,
client_key: t.Union[DefaultType, str] = DEFAULT,
ssl_assert_hostname: t.Union[DefaultType, str] = DEFAULT,
ssl_assert_fingerprint: t.Union[DefaultType, str] = DEFAULT,
ssl_version: t.Union[DefaultType, int] = DEFAULT,
ssl_context: t.Union[DefaultType, t.Any] = DEFAULT,
ssl_show_warn: t.Union[DefaultType, bool] = DEFAULT,
# Transport
transport_class: t.Type[Transport] = Transport,
request_timeout: t.Union[DefaultType, None, float] = DEFAULT,
node_class: t.Union[DefaultType, t.Type[BaseNode]] = DEFAULT,
node_pool_class: t.Union[DefaultType, t.Type[NodePool]] = DEFAULT,
randomize_nodes_in_pool: t.Union[DefaultType, bool] = DEFAULT,
node_selector_class: t.Union[DefaultType, t.Type[NodeSelector]] = DEFAULT,
dead_node_backoff_factor: t.Union[DefaultType, float] = DEFAULT,
max_dead_node_backoff: t.Union[DefaultType, float] = DEFAULT,
serializer: t.Optional[Serializer] = None,
serializers: t.Union[DefaultType, t.Mapping[str, Serializer]] = DEFAULT,
default_mimetype: str = "application/json",
max_retries: t.Union[DefaultType, int] = DEFAULT,
retry_on_status: t.Union[DefaultType, int, t.Collection[int]] = DEFAULT,
retry_on_timeout: t.Union[DefaultType, bool] = DEFAULT,
sniff_on_start: t.Union[DefaultType, bool] = DEFAULT,
sniff_before_requests: t.Union[DefaultType, bool] = DEFAULT,
sniff_on_node_failure: t.Union[DefaultType, bool] = DEFAULT,
sniff_timeout: t.Union[DefaultType, None, float] = DEFAULT,
min_delay_between_sniffing: t.Union[DefaultType, None, float] = DEFAULT,
sniffed_node_callback: t.Optional[
t.Callable[[t.Dict[str, t.Any], NodeConfig], t.Optional[NodeConfig]]
] = None,
meta_header: t.Union[DefaultType, bool] = DEFAULT,
http_auth: t.Union[DefaultType, t.Any] = DEFAULT,
# Internal use only
_transport: t.Optional[Transport] = None,
) -> None:
这是Elasticsearch9.0.2库的初始化参数
最新发布