# opensearch-project/opensearch-py architecture

> Architecture diagram of the GitHub repository opensearch-project/opensearch-py, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/opensearch-project/opensearch-py
- Repository: https://github.com/opensearch-project/opensearch-py

## Overview

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: [`opensearchpy/client/__init__.py`](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/__init__.py) (OpenSearch client), [`opensearchpy/transport.py`](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/transport.py) (Request transport), [`opensearchpy/helpers/search.py`](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/search.py) (Search builder), [`opensearchpy/helpers/index.py`](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/index.py) (Index model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Client APIs"]
  node_client["OpenSearch client<br/>[__init__.py]"]
  node_domain["Domain endpoints<br/>[indices.py]"]
  node_asyncclient["Async client APIs<br/>[client.py]"]
  node_grpcclient["gRPC client<br/>[grpc_client.py]"]
end

subgraph group_dsl["Search And Modeling"]
  node_search["Search builder<br/>[search.py]"]
  node_query["Query DSL<br/>[query.py]"]
  node_indexmodel["Index model<br/>[index.py]"]
  node_mapping["Mappings and fields<br/>[mapping.py]"]
  node_update["Update by query<br/>[update_by_query.py]"]
end

subgraph group_wire["Transport And Connections"]
  node_grpcwire["gRPC transport<br/>[grpc_transport.py]"]
  node_transport["Request transport<br/>[transport.py]"]
  node_pool["Connection pool<br/>[connection_pool.py]"]
  node_connections["Connection management<br/>[connections.py]"]
  node_http["HTTP connection<br/>[http_urllib3.py]"]
  node_serializer["Serialization<br/>[serializer.py]"]
end

subgraph group_extensions["Plugins And Metrics"]
  node_plugins["Plugin APIs<br/>[query.py]"]
  node_metrics["Metrics<br/>[metrics.py]"]
end

node_user(("Application"))
node_cluster[("OpenSearch cluster")]

node_user -->|"calls"| node_client
node_user -->|"builds queries"| node_search
node_user -->|"calls"| node_grpcclient
node_client -->|"exposes"| node_domain
node_client -->|"configures"| node_transport
node_grpcclient -->|"uses"| node_grpcwire
node_search -->|"composes"| node_query
node_search -->|"executes requests"| node_client
node_indexmodel -->|"creates indices"| node_domain
node_indexmodel -->|"uses mappings"| node_mapping
node_update -->|"builds filters"| node_query
node_transport -->|"selects connections"| node_pool
node_transport -->|"serializes payloads"| node_serializer
node_pool -->|"holds connections"| node_connections
node_connections -->|"uses HTTP"| node_http
node_http -->|"sends requests"| node_cluster
node_grpcwire -.->|"sends RPCs"| node_cluster
node_transport -->|"records events"| node_metrics
node_plugins -->|"uses transport"| node_client

click node_client "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/__init__.py"
click node_domain "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/indices.py"
click node_asyncclient "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/_async/client/client.py"
click node_grpcclient "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/grpc_client.py"
click node_plugins "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/plugins/query.py"
click node_search "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/search.py"
click node_query "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/query.py"
click node_indexmodel "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/index.py"
click node_mapping "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/mapping.py"
click node_update "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/update_by_query.py"
click node_grpcwire "https://github.com/opensearch-project/opensearch-py/blob/main/opensearch_grpc/grpc_transport.py"
click node_transport "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/transport.py"
click node_pool "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection_pool.py"
click node_connections "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection/connections.py"
click node_http "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection/http_urllib3.py"
click node_serializer "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/serializer.py"
click node_metrics "https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/metrics/metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_domain,node_asyncclient,node_grpcclient toneBlue
class node_search,node_query,node_indexmodel,node_mapping,node_update,node_cluster toneAmber
class node_grpcwire,node_transport,node_pool,node_connections,node_http,node_serializer toneMint
class node_plugins,node_metrics toneRose
class node_user toneIndigo
```

## Components

### Client APIs

- [OpenSearch client](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/__init__.py): `opensearchpy/client/__init__.py`
- [Domain endpoints](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/indices.py): `opensearchpy/client/indices.py`
- [Async client APIs](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/_async/client/client.py): `opensearchpy/_async/client/client.py`
- [gRPC client](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/client/grpc_client.py): `opensearchpy/client/grpc_client.py`

### Search And Modeling

- [Search builder](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/search.py): `opensearchpy/helpers/search.py`
- [Query DSL](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/query.py): `opensearchpy/helpers/query.py`
- [Index model](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/index.py): `opensearchpy/helpers/index.py`
- [Mappings and fields](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/mapping.py): `opensearchpy/helpers/mapping.py`
- [Update by query](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/helpers/update_by_query.py): `opensearchpy/helpers/update_by_query.py`

### Transport And Connections

- [gRPC transport](https://github.com/opensearch-project/opensearch-py/blob/main/opensearch_grpc/grpc_transport.py): `opensearch_grpc/grpc_transport.py`
- [Request transport](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/transport.py): `opensearchpy/transport.py`
- [Connection pool](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection_pool.py): `opensearchpy/connection_pool.py`
- [Connection management](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection/connections.py): `opensearchpy/connection/connections.py`
- [HTTP connection](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/connection/http_urllib3.py): `opensearchpy/connection/http_urllib3.py`
- [Serialization](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/serializer.py): `opensearchpy/serializer.py`

### Plugins And Metrics

- [Plugin APIs](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/plugins/query.py): `opensearchpy/plugins/query.py`
- [Metrics](https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/metrics/metrics.py): `opensearchpy/metrics/metrics.py`

### Other components

- **Application**
- **OpenSearch cluster**

## Connections

- Application → OpenSearch client: calls
- Application → Search builder: builds queries
- Application → gRPC client: calls
- OpenSearch client → Domain endpoints: exposes (evidence: `opensearchpy/client/__init__.py`)
- OpenSearch client → Request transport: configures (evidence: `opensearchpy/client/__init__.py`)
- gRPC client → gRPC transport: uses (evidence: `opensearchpy/client/grpc_client.py`)
- Search builder → Query DSL: composes (evidence: `opensearchpy/helpers/search.py`)
- Search builder → OpenSearch client: executes requests (evidence: `opensearchpy/helpers/search.py`)
- Index model → Domain endpoints: creates indices (evidence: `opensearchpy/helpers/index.py`)
- Index model → Mappings and fields: uses mappings (evidence: `opensearchpy/helpers/index.py`)
- Update by query → Query DSL: builds filters (evidence: `opensearchpy/helpers/update_by_query.py`)
- Request transport → Connection pool: selects connections (evidence: `opensearchpy/transport.py`)
- Request transport → Serialization: serializes payloads (evidence: `opensearchpy/transport.py`)
- Connection pool → Connection management: holds connections (evidence: `opensearchpy/connection_pool.py`)
- Connection management → HTTP connection: uses HTTP (evidence: `opensearchpy/connection/http_urllib3.py`)
- HTTP connection → OpenSearch cluster: sends requests (evidence: `opensearchpy/connection/http_urllib3.py`)
- gRPC transport → OpenSearch cluster: sends RPCs
- Request transport → Metrics: records events (evidence: `opensearchpy/transport.py`)
- Plugin APIs → OpenSearch client: uses transport (evidence: `opensearchpy/plugins/query.py`)
