Skip to main content

Crate opensearch_client

Crate opensearch_client 

Source
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 building
  • indices - Index management and operations
  • cluster - 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§

BulkError
BulkItemResponse
BulkResponse
Bulker
Bulker is a helper struct to make bulk requests to OpenSearch.
BulkerBuilder
BulkerStatistic
Configuration
ConfigurationBuilder
CreateAction
DeleteAction
Field
IndexAction
IndexResponse
OsClient
ResponseContent
Script
UpdateAction
UpdateActionBody

Enums§

BulkAction
Error

Traits§

Document

Functions§

get_opensearch
set_opensearch

Derive Macros§

OpenSearch