How opensearch-project/opensearch-py works
opensearch-py is a Python client for issuing OpenSearch operations through synchronous and asynchronous APIs, with an additional gRPC client. The main workflow is application code calling a domain API or query helper, which forms requests and hands them to transport for node selection, serialization, and HTTP/gRPC communication with an OpenSearch cluster. Helpers cover index/document modeling, search and query composition, and bulk/update workflows; namespaced APIs extend cluster, index, security, and plugin operations. The tree and excerpts establish these layers, but not every client-to-transport call path or async detail, so uncertain connections are omitted.
Main entry points: __init__.py OpenSearch client · transport.py Request transport · search.py Search builder · index.py Index model
Components 19
Client APIs
- OpenSearch client
opensearchpy/client/__init__.py - Domain endpoints
opensearchpy/client/indices.py - Async client APIs
opensearchpy/_async/client/client.py - gRPC client
opensearchpy/client/grpc_client.py
Search And Modeling
- Search builder
opensearchpy/helpers/search.py - Query DSL
opensearchpy/helpers/query.py - Index model
opensearchpy/helpers/index.py - Mappings and fields
opensearchpy/helpers/mapping.py - Update by query
opensearchpy/helpers/update_by_query.py
Transport And Connections
- gRPC transport
opensearch_grpc/grpc_transport.py - Request transport
opensearchpy/transport.py - Connection pool
opensearchpy/connection_pool.py - Connection management
opensearchpy/connection/connections.py - HTTP connection
opensearchpy/connection/http_urllib3.py - Serialization
opensearchpy/serializer.py
Plugins And Metrics
- Plugin APIs
opensearchpy/plugins/query.py - Metrics
opensearchpy/metrics/metrics.py
Other components
- Application
- OpenSearch cluster
Connections 19
- Application → OpenSearch client: calls
- Application → Search builder: builds queries
- Application → gRPC client: calls
- OpenSearch client → Domain endpoints: exposes
opensearchpy/client/__init__.py - OpenSearch client → Request transport: configures
opensearchpy/client/__init__.py - gRPC client → gRPC transport: uses
opensearchpy/client/grpc_client.py - Search builder → Query DSL: composes
opensearchpy/helpers/search.py - Search builder → OpenSearch client: executes requests
opensearchpy/helpers/search.py - Index model → Domain endpoints: creates indices
opensearchpy/helpers/index.py - Index model → Mappings and fields: uses mappings
opensearchpy/helpers/index.py - Update by query → Query DSL: builds filters
opensearchpy/helpers/update_by_query.py - Request transport → Connection pool: selects connections
opensearchpy/transport.py - Request transport → Serialization: serializes payloads
opensearchpy/transport.py - Connection pool → Connection management: holds connections
opensearchpy/connection_pool.py - Connection management → HTTP connection: uses HTTP
opensearchpy/connection/http_urllib3.py - HTTP connection → OpenSearch cluster: sends requests
opensearchpy/connection/http_urllib3.py - gRPC transport → OpenSearch cluster: sends RPCs
- Request transport → Metrics: records events
opensearchpy/transport.py - Plugin APIs → OpenSearch client: uses transport
opensearchpy/plugins/query.py