Expand description
§OpenSearch Client for Rust
A comprehensive Rust client library for OpenSearch with strongly typed APIs and async support.
§Features
- Strongly Typed: Type-safe APIs with compile-time guarantees
- Async/Await: Built on tokio for high-performance async operations
- Comprehensive Coverage: Support for search, indices, cluster management, and more
- Modular Design: Feature flags for optional functionality
- Production Ready: Includes retry logic, connection pooling, and error handling
§Quick Start
use opensearch_client::{ConfigurationBuilder, OsClient};
use opensearch_dsl::*;
use url::Url;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client configuration
let config = ConfigurationBuilder::new()
.base_url(Url::parse("http://localhost:9200")?)
.basic_auth("admin".to_string(), "admin".to_string())
.build();
let client = OsClient::new(config);
// Perform a search
let search = Search::new()
.query(Query::match_("title", "opensearch"))
.size(10);
let response = client.search(&search).index("my_index").await?;
for hit in response.hits.hits {
println!("Document: {:?}", hit.source);
}
Ok(())
}§Module Organization
search- Search operations and query buildingindices- Index management and operationscluster- Cluster health and management- [
bulk] - Bulk operations for efficient data processing dsl- Re-export of opensearch-dsl for query building
§Feature Flags
Enable only the features you need:
[dependencies]
opensearch-client = { version = "0.3", features = [
"search",
"indices",
"cluster"
] }Re-exports§
pub extern crate opensearch_dsl;pub use opensearch_dsl as dsl;
Modules§
- cluster
- Cluster-level operations including health monitoring and settings management.
- common
- Common types and utilities used across the client.
- core
- Core client functionality and configuration.
- indices
- ingest
- ml
- query
- search
- tasks
Structs§
- Bulk
Error - Bulk
Item Response - Bulk
Response - Bulker
- Bulker is a helper struct to make bulk requests to OpenSearch.
- Bulker
Builder - Bulker
Statistic - Configuration
- Configuration
Builder - Create
Action - Delete
Action - Field
- Index
Action - Index
Response - OsClient
- Response
Content - Script
- Update
Action - Update
Action Body