OpenSearch Python Client

3.1.0 · active · verified Tue Mar 24

Official Python client for OpenSearch — AWS's Apache 2.0 fork of Elasticsearch 7.10. Current version: 3.1.0 (Mar 2026). API is nearly identical to elasticsearch-py v7 but NOT interchangeable — different package, different import. OpenSearch 1.x deprecated May 2025. v3.0 client released alongside OpenSearch 3.0. Major footgun: developers import elasticsearch instead of opensearch_py by mistake. Also compatible with Amazon OpenSearch Service (AWS managed).

Warnings

Install

Imports

Quickstart

Minimal opensearch-py connection and CRUD.

# pip install opensearch-py
from opensearchpy import OpenSearch

client = OpenSearch(
    hosts=[{'host': 'localhost', 'port': 9200}],
    http_auth=('admin', 'admin'),
    use_ssl=False
)

# Create index
client.indices.create(
    index='products',
    body={
        'mappings': {
            'properties': {
                'name': {'type': 'text'},
                'price': {'type': 'float'}
            }
        }
    }
)

# Index document
client.index(index='products', id='1', body={'name': 'Widget', 'price': 9.99})

# Search
resp = client.search(
    index='products',
    body={'query': {'match': {'name': 'Widget'}}}
)
for hit in resp['hits']['hits']:
    print(hit['_source'])

view raw JSON →