OpenSearch Client for Rust
A comprehensive Rust client library for OpenSearch with a strongly typed DSL, CLI tools, and extensive API coverage.
Features
- Strongly Typed DSL — type-safe query building with compile-time guarantees
- Comprehensive API Coverage — search, indices, cluster, ML, security, snapshot, and more
- Document ORM —
#[derive(OpenSearch)]macro generates a fullDocumenttrait on your structs - CLI Tools —
opensearch-clifor cluster management and data migration - Async/Await — built on tokio; every I/O call is non-blocking
- Production Ready — retry logic, connection pooling, and typed error handling
- Modular — feature flags let you compile only the API groups you use
Project Structure
| Crate | Description |
|---|---|
opensearch-client |
Core HTTP client and all OpenSearch API bindings |
opensearch-dsl |
Standalone, strongly typed query/aggregation DSL |
opensearch-macro |
#[derive(OpenSearch)] proc-macro |
opensearch-cli |
CLI tool for cluster management and data operations |
opensearch-testcontainer |
Docker-based test fixtures via testcontainers |
Installation
[]
= "0.3"
= "0.3"
Macro support is bundled with opensearch-client — no extra dependency needed.
Quick Start
use ;
use *;
use Url;
async
See docs/getting-started.md for the full walkthrough, including environment-variable setup and first-index examples.
Document Modeling
The #[derive(OpenSearch)] macro turns a plain Rust struct into a first-class OpenSearch document:
use ;
use ;
This generates save(), get(), delete(), find(), find_all(), and count() directly on the type:
article.save.await?;
let a = get.await?;
delete.await?;
let results = find.await?;
Full reference: docs/documents/
Documentation
API docs for the latest release are published at docs.rs/opensearch-client.
CLI Tools
See docs/cli.md for all subcommands and flags.
Testing
# Unit tests
# Integration tests (requires a running OpenSearch instance)
See docs/testing.md for the full testing guide.
Contributing
Contributions are welcome. Please read docs/contributing.md and CONTRIBUTING.md before opening a pull request.
License
Apache 2.0 — see LICENSE.
Related Projects
- OpenSearch
- opensearch-rs — the official Rust client
- elasticsearch-dsl-rs — DSL inspiration