The Python Way to Elasticsearch

Simplify Elasticsearch
Amplify Productivity

You Know, For Elasticsearch 

Elastro turns Elasticsearch into a high-velocity developer tool that replaces verbose REST calls with focused Python constructs and a unified CLI. Now teams can build, test, and automate faster.

example.py
1from elastro import ElasticsearchClient, DocumentManager
2from elastro.advanced import QueryBuilder
3 
4# Initialize and connect
5client = ElasticsearchClient()
6client.connect()
7doc_manager = DocumentManager(client)
8 
9# Build queries with QueryBuilder
10query_builder = QueryBuilder()
11bool_query = query_builder.bool()
12bool_query.must(QueryBuilder().match("name", "laptop"))
13bool_query.must(QueryBuilder().range("price", gte=500, lte=2000))
14query = query_builder.build()
15 
16results = doc_manager.search("products", query)
17print(f"Found {results['hits']['total']['value']} products!")
Everything You Need

Features that make Elasticsearch feel effortless

From index management to complex aggregations, Elastro provides a complete toolkit for Python developers working with Elasticsearch.

Index Management

Create, update, and delete indices with intuitive methods. No more complex JSON mappings.

Powerful Query Builder

Build complex queries with a fluent, chainable API. Match, filter, range, and more.

CLI & API Combined

Use the command-line for quick operations or integrate seamlessly via Python API.

Advanced Aggregations

Powerful aggregation builder for analytics, metrics, and data visualization.

Cluster Health Checks

Score findings with collectors and rules, dry-run fixes, rollback snapshots, and --fail-on CI gates.

Type-Safe with Pydantic

Built-in validation and type safety using Pydantic models for reliable data handling.

Smart Ingest Engine

Client-side data processing, format conversion (CSV, SQL, NDJSON), and pre-flight schema validation.

Local GUI & ES|QL

Launch a local web GUI with elastro gui, and run or build ES|QL queries from the CLI.

Fluent QueryBuilder
One CLI + SDK
MIT Licensed
Well Documented
Before & After

Write cleaner code, faster

See how Elastro transforms verbose Elasticsearch interactions into elegant, readable Python code.

Before Elastro
Traditional elasticsearch-py
query_before.py
1from elasticsearch import Elasticsearch
2 
3es = Elasticsearch(['http://localhost:9200'])
4 
5# Complex nested dictionary structure
6query = {
7 "query": {
8 "bool": {
9 "must": [
10 {"match": {"name": "laptop"}},
11 {"range": {
12 "price": {
13 "gte": 500,
14 "lte": 2000
15 }
16 }}
17 ]
18 }
19 },
20 "sort": [{"rating": {"order": "desc"}}],
21 "size": 10
22}
23 
24results = es.search(index="products", body=query)

❌ Verbose • ❌ Error-prone • ❌ Hard to maintain

With Elastro
Clean, fluent API
query_after.py
1from elastro import ElasticsearchClient, DocumentManager
2from elastro.advanced import QueryBuilder
3 
4client = ElasticsearchClient()
5client.connect()
6doc_manager = DocumentManager(client)
7 
8# Clean, builder API
9query_builder = QueryBuilder()
10bool_query = query_builder.bool()
11bool_query.must(QueryBuilder().match("name", "laptop"))
12bool_query.must(QueryBuilder().range("price", gte=500, lte=2000))
13query = query_builder.build()
14 
15results = doc_manager.search(
16 "products",
17 query,
18 {"sort": [{"rating": {"order": "desc"}}], "size": 10}
19)

✓ Readable • ✓ Type-safe • ✓ Maintainable

No nested
query dicts
One CLI
+ Python SDK
MIT
licensed
Ready in Seconds

Get started in one command

Install Elastro and start simplifying your Elasticsearch operations immediately.

$ pip install elastro-client

Python 3.10–3.13 · MIT license · PyPI package elastro-client

Quick Start Example

quickstart.py
1from elastro import ElasticsearchClient, IndexManager, DocumentManager
2from elastro.advanced import QueryBuilder
3 
4# Connect to your Elasticsearch cluster
5client = ElasticsearchClient(
6 hosts=["http://localhost:9200"]
7)
8client.connect()
9 
10# Create managers
11index_manager = IndexManager(client)
12doc_manager = DocumentManager(client)
13 
14# Create an index with mappings
15index_manager.create(
16 "my_index",
17 mappings={
18 "properties": {
19 "title": {"type": "text"},
20 "views": {"type": "integer"}
21 }
22 }
23)
24 
25# Index a document
26doc_manager.index(
27 "my_index",
28 id="1",
29 document={"title": "Hello Elastro!", "views": 100}
30)
31 
32# Search with QueryBuilder
33query_builder = QueryBuilder()
34query_builder.match_all()
35query = query_builder.build()
36results = doc_manager.search("my_index", query)
37print(results["hits"]["hits"])