Integrations

edit

You can find integration options and information on this page.

OpenTelemetry instrumentation

edit

The Python Elasticsearch client supports native OpenTelemetry instrumentation following the OpenTelemetry Semantic Conventions for Elasticsearch. Refer to the Using OpenTelemetry page for details.

ES|QL

edit

ES|QL is available through the Python Elasticsearch client. Refer to the ES|QL and Pandas page to learn more about using ES|QL and Pandas together with dataframes.

Transport

edit

The handling of connections, retries, and pooling is handled by the Elastic Transport Python library. Documentation on the low-level classes is available on Read the Docs.

Tracking requests with Opaque ID

edit

You can enrich your requests against Elasticsearch with an identifier string, that allows you to discover this identifier in deprecation logs, to support you with identifying search slow log origin or to help with identifying running tasks.

The opaque ID can be set via the opaque_id parameter via the client .options() method:

client = Elasticsearch(...)
client.options(opaque_id="request-id-...").search(...)

Type Hints

edit

Starting in elasticsearch-py v7.10.0 the library now ships with type hints and supports basic static type analysis with tools like Mypy and Pyright.

If we write a script that has a type error like using request_timeout with a str argument instead of float and then run Mypy on the script:

# script.py
from elasticsearch import Elasticsearch

client = Elasticsearch(...)
client.options(
    request_timeout="5"  # type error!
).search(...)

# $ mypy script.py
# script.py:5: error: Argument "request_timeout" to "search" of "Elasticsearch" has
#                     incompatible type "str"; expected "Union[int, float, None]"
# Found 1 error in 1 file (checked 1 source file)

Type hints also allow tools like your IDE to check types and provide better auto-complete functionality.