Skip to main content

Elastro

      .   *   .       .   *   .      .
    .   _   .   *   .    *    .   *
  _ __| | __ _ ___| |_ _ __ ___    .
  / _ \ |/ _` / __| __| '__/ _ \  *
 |  __/ | (_| \__ \ |_| | | (_) |  .
  \___|_|\__,_|___/\__|_|  \___/ .
      .    *     .      *    .   *

License: MIT Python 3.10–3.13 Code style: Ruff

A comprehensive Python module for managing Elasticsearch operations within pipeline processes.

Overview

Elastro is a Python library designed to simplify interactions with Elasticsearch. It provides a clean, intuitive API for common Elasticsearch operations including:

  • Index management (create, update, delete)
  • Document operations (indexing, searching, updating)
  • Datastream management
  • Advanced query building and search functionality

The library offers both a programmatic API and a command-line interface for seamless integration with various workflows.

Table of Contents

Installation

Global CLI Installation (Recommended)

To heavily simplify installation across all operating systems and elegantly check your Python compatibility, run our automated install.sh via curl:

# WARNING: piping curl to bash skips checksum verification.
# Safer path (recommended): download, inspect, then run:
#   curl -sSfL https://raw.githubusercontent.com/Fremen-Labs/elastro/main/install.sh -o /tmp/elastro-install.sh
#   less /tmp/elastro-install.sh
#   bash /tmp/elastro-install.sh
# Or skip the installer entirely with pipx (below).
curl -sSfL https://raw.githubusercontent.com/Fremen-Labs/elastro/main/install.sh | bash

Alternatively, if you already have pipx installed and your Python version is compatible (>=3.10, <3.14):

# Manual installation via pipx
pipx install elastro-client

# Upgrade later
pipx upgrade elastro-client

Library Installation (For Development)

If you are using Elastro as a library in your Python project:

# Using a virtual environment
python3 -m venv venv
source venv/bin/activate
pip install elastro-client

Troubleshooting: "externally-managed-environment"

If you see an externally-managed-environment error when running pip install, it means your OS (like macOS with Homebrew) prevents system-wide package installation.

Solution: Use pipx (above) or a virtual environment. Do not use --break-system-packages unless you are certain of the consequences.

Basic Usage

Client Connection

from elastro import ElasticsearchClient

# Connect using API key
client = ElasticsearchClient(
    hosts=["https://elasticsearch:9200"], auth={"api_key": "your-api-key"}
)

# Or using basic auth
client = ElasticsearchClient(
    hosts=["https://elasticsearch:9200"],
    auth={"username": "elastic", "password": "password"},
)

# Connect to Elasticsearch
client.connect()

Index Management

from elastro import IndexManager

index_manager = IndexManager(client)

# Create an index
index_manager.create(
    name="products",
    settings={"number_of_shards": 3, "number_of_replicas": 1},
    mappings={
        "properties": {
            "name": {"type": "text"},
            "price": {"type": "float"},
            "description": {"type": "text"},
            "created": {"type": "date"},
        }
    },
)

# Check if an index exists
if index_manager.exists("products"):
    print("Products index exists!")

# Delete an index
index_manager.delete("products")

Document Operations

from elastro import DocumentManager

doc_manager = DocumentManager(client)

# Index a document
doc_manager.index(
    index="products",
    id="1",
    document={
        "name": "Laptop",
        "price": 999.99,
        "description": "High-performance laptop",
        "created": "2023-05-01T12:00:00",
    },
)

# Search for documents
results = doc_manager.search(index="products", query={"match": {"name": "laptop"}})

print(results)

CLI Usage

# Initialize configuration
elastro config init

# Launch the Elastro Local Web GUI
elastro gui

# Create an index
elastro index create products --shards 3 --replicas 1

# Interactive Template Wizard
elastro template wizard

# Interactive ILM Policy Wizard
elastro ilm create my-policy

# List ILM Policies (Table View)
elastro ilm list

# Add a document
elastro doc index products --id 1 --file ./product.json

# Search documents
elastro doc search products --term category=laptop

# Health assessment (scored findings, remediation, rollback)
elastro health assess -o table
elastro health score
elastro health assess --fix --dry-run -o table
elastro health assess --history -o table
elastro health rollback --id rb-abc123 --dry-run
elastro health shards --analyze
elastro health hotspots
elastro health lint -o table

# Classic cluster status (prefer over utils health)
elastro health status

# Data Ingest & Processing (Client-Side)
elastro ingest import data.csv --index customers --format csv
elastro ingest profile data.csv --sample-size 1000
elastro ingest auto-map data.json --sample-size 500
elastro ingest grok-builder --sample "10.0.0.1 - - [12/May/2026:07:03:12] \"GET /api/v1/users HTTP/1.1\" 200 1234"

# Manage server-side ingest pipelines
elastro ingest pipelines
elastro ingest simulate my-pipeline --docs ./docs.json

# Manage native realm security users and roles
elastro security users list
elastro security roles create my-role --privileges "monitor,manage"

# View long-running cluster tasks
elastro tasks list --detailed

ILM (Index Lifecycle Management)

Elastro provides a powerful CLI for managing ILM policies, including an interactive wizard.

# List all policies (Table View)
elastro ilm list

# List with full JSON details (limited to first 2)
elastro ilm list --full

# Create a policy using the Interactive Wizard (Recommended)
elastro ilm create my-policy
# Follow the prompts to configure Hot, Warm, Cold, and Delete phases.

# Create a policy from a file
elastro ilm create my-policy --file ./policy.json

# Explain lifecycle status for an index (includes step info for debugging)
elastro ilm explain my-index

Snapshot & Restore

Manage backup repositories and snapshots with ease.

Repositories:

# List all repositories
elastro snapshot repo list

# Create a filesystem repository
elastro snapshot repo create my_backup fs --setting location=/tmp/backups

# Create an S3 repository
elastro snapshot repo create my_s3_backup s3 --setting bucket=my-bucket --setting region=us-east-1

Snapshots:

# List snapshots in a repository
elastro snapshot list my_backup

# Create a snapshot (async default)
elastro snapshot create my_backup snapshot_1

# Create and wait for completion
elastro snapshot create my_backup snapshot_2 --wait --indices "logs-*,metrics-*"

# Restore a snapshot (Interactive Wizard)
elastro snapshot restore
# Launches a wizard to select repo -> snapshot -> indices -> rename pattern

# Restore specific indices from CLI
elastro snapshot restore my_backup snapshot_1 --indices "logs-*"

Documentation

For full details, refer to the guides in the docs/ directory:

Examples

Check out the examples directory for more usage examples:

Contributing

We welcome contributions to Elastro! Please see CONTRIBUTING.md for guidelines on how to get started, code standards, and submission processes.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elastro_client-1.13.4.tar.gz (486.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elastro_client-1.13.4-py3-none-any.whl (412.8 kB view details)

Uploaded Python 3

File details

Details for the file elastro_client-1.13.4.tar.gz.

File metadata

  • Download URL: elastro_client-1.13.4.tar.gz
  • Upload date:
  • Size: 486.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for elastro_client-1.13.4.tar.gz
Algorithm Hash digest
SHA256 4cac643a333d9709f07838aef7228b10836914b62397e7ace6228ba0be6c1842
MD5 710bad54e24c5127021f95c4b86ae4b9
BLAKE2b-256 69edca33381192898793d8519f29b352d4966eba04a2717697cd14ebb89a374d

See more details on using hashes here.

File details

Details for the file elastro_client-1.13.4-py3-none-any.whl.

File metadata

  • Download URL: elastro_client-1.13.4-py3-none-any.whl
  • Upload date:
  • Size: 412.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for elastro_client-1.13.4-py3-none-any.whl
Algorithm Hash digest
SHA256 54bc969e2a86835bdcaa86e0955262d5e5d6c238ab7b93908d9a360f39544e15
MD5 7261d2dc13773a42c62d72ebf44ee422
BLAKE2b-256 adb9d41cea8dbd29b9c5f11bd958704b2d945b8dbecb616e018276bd3a6ff74c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.13.4 This release

2 files

1.13.3

2 files

1.13.1

2 files

1.3.59

2 files

1.3.58

2 files

1.3.57

2 files

1.3.56

2 files

1.3.55

2 files

1.3.54

2 files

1.3.53

2 files

1.3.52

2 files

1.3.51

2 files

1.3.50

2 files

1.3.49

2 files

1.3.48

2 files

1.3.47

2 files

1.3.46

2 files

1.3.45

2 files

1.3.44

2 files

1.3.43

2 files

1.3.42

2 files

1.3.41

2 files

1.3.40

2 files

1.3.39

2 files

1.3.38

2 files

1.3.37

2 files

1.3.36

2 files

1.3.34

2 files

1.3.32

2 files

1.3.31

2 files

1.3.30

2 files

1.3.29

2 files

1.3.28

2 files

1.3.27

2 files

1.3.26

2 files

1.3.25

2 files

1.3.24

2 files

1.3.23

2 files

1.3.22

2 files

1.3.21

2 files

1.3.20

2 files

1.3.19

2 files

1.3.18

2 files

1.3.17

2 files

1.3.16

2 files

1.3.15

2 files

1.3.13

2 files

1.3.11

2 files

1.3.10

2 files

1.3.8

2 files

1.3.7

2 files

1.3.6

2 files

1.3.5

2 files

1.3.4

2 files

1.2.8

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page