Simplify Elasticsearch
Amplify Productivity
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.
1from elastro import ElasticsearchClient, DocumentManager2from elastro.advanced import QueryBuilder3 4# Initialize and connect5client = ElasticsearchClient()6client.connect()7doc_manager = DocumentManager(client)8 9# Build queries with QueryBuilder10query_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!")from elastro import ElasticsearchClient, DocumentManager
from elastro.advanced import QueryBuilder
# Initialize and connect
client = ElasticsearchClient()
client.connect()
doc_manager = DocumentManager(client)
# Build queries with QueryBuilder
query_builder = QueryBuilder()
bool_query = query_builder.bool()
bool_query.must(QueryBuilder().match("name", "laptop"))
bool_query.must(QueryBuilder().range("price", gte=500, lte=2000))
query = query_builder.build()
results = doc_manager.search("products", query)
print(f"Found {results['hits']['total']['value']} products!")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.
Write cleaner code, faster
See how Elastro transforms verbose Elasticsearch interactions into elegant, readable Python code.
1from elasticsearch import Elasticsearch2 3es = Elasticsearch(['http://localhost:9200'])4 5# Complex nested dictionary structure6query = {7 "query": {8 "bool": {9 "must": [10 {"match": {"name": "laptop"}},11 {"range": {12 "price": {13 "gte": 500,14 "lte": 200015 }16 }}17 ]18 }19 },20 "sort": [{"rating": {"order": "desc"}}],21 "size": 1022}23 24results = es.search(index="products", body=query)❌ Verbose • ❌ Error-prone • ❌ Hard to maintain
1from elastro import ElasticsearchClient, DocumentManager2from elastro.advanced import QueryBuilder3 4client = ElasticsearchClient()5client.connect()6doc_manager = DocumentManager(client)7 8# Clean, builder API9query_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
Get started in one command
Install Elastro and start simplifying your Elasticsearch operations immediately.
$ pip install elastro-clientPython 3.10–3.13 · MIT license · PyPI package elastro-client
Quick Start Example
1from elastro import ElasticsearchClient, IndexManager, DocumentManager2from elastro.advanced import QueryBuilder3 4# Connect to your Elasticsearch cluster5client = ElasticsearchClient(6 hosts=["http://localhost:9200"]7)8client.connect()9 10# Create managers11index_manager = IndexManager(client)12doc_manager = DocumentManager(client)13 14# Create an index with mappings15index_manager.create(16 "my_index",17 mappings={18 "properties": {19 "title": {"type": "text"},20 "views": {"type": "integer"}21 }22 }23)24 25# Index a document26doc_manager.index(27 "my_index",28 id="1",29 document={"title": "Hello Elastro!", "views": 100}30)31 32# Search with QueryBuilder33query_builder = QueryBuilder()34query_builder.match_all()35query = query_builder.build()36results = doc_manager.search("my_index", query)37print(results["hits"]["hits"])