elasticsearch-py is the official Python package for talking to Elasticsearch clusters, with sync and async clients plus helpers.
Overview
The Elasticsearch Python client is the official library for using Elasticsearch from Python applications. It maps Python types to JSON, sends requests to the full Elasticsearch HTTP API, and is designed to be unopinionated and extensible.
The core client supports automatic node discovery, persistent connections, load balancing across nodes, TLS and HTTP authentication, thread-safe requests, and timeouts on transient errors. Helper modules add bulk ingest utilities, an ES|QL query builder, and a DSL for expressing documents and queries as Python objects instead of raw dicts.
Client releases track Elasticsearch major and minor versions with forward and backward compatibility rules documented by Elastic. Separate PyPI package names exist for pinning major versions when multiple clients are needed in one environment.
Installation is through pip alongside a running Elasticsearch deployment or Elastic Cloud trial. Documentation covers connection setup, API usage, and compatibility matrices on elastic.co and Read the Docs.
Key features
- Sync and async Elasticsearch clients
- Automatic cluster node discovery
- TLS and HTTP authentication
- Bulk ingest helper functions
- ES|QL query builder module
- Python DSL for documents and queries
- Load balancing across nodes
- Pluggable client architecture
Use cases
- Indexing and searching data from Python apps
- Bulk data ingestion pipelines
- Building search features in web backends
- Scripted Elasticsearch administration