pub struct Elasticsearch { /* private fields */ }
Expand description

Root client for top level APIs

Implementations

Creates a namespace client for AsyncSearch APIs

Creates a namespace client for Autoscaling APIs

Creates a namespace client for Cat APIs

Creates a namespace client for Cross Cluster Replication APIs

Creates a namespace client for Cluster APIs

Creates a namespace client for DanglingIndices APIs

Creates a namespace client for Enrich APIs

Creates a namespace client for Eql APIs

Creates a namespace client for Features APIs

Creates a namespace client for Fleet APIs

Creates a namespace client for Graph APIs

Creates a namespace client for Index Lifecycle Management APIs

Creates a namespace client for Indices APIs

Creates a namespace client for Ingest APIs

Creates a namespace client for License APIs

Creates a namespace client for Logstash APIs

Creates a namespace client for Migration APIs

Creates a namespace client for Machine Learning APIs

Creates a namespace client for Monitoring APIs

Creates a namespace client for Nodes APIs

Creates a namespace client for Rollup APIs

Creates a namespace client for SearchableSnapshots APIs

Creates a namespace client for Security APIs

Creates a namespace client for Shutdown APIs

Creates a namespace client for Snapshot Lifecycle Management APIs

Creates a namespace client for Snapshot APIs

Creates a namespace client for Sql APIs

Creates a namespace client for Ssl APIs

Creates a namespace client for Tasks APIs

Creates a namespace client for TextStructure APIs

Creates a namespace client for Transform APIs

Creates a namespace client for Watcher APIs

Creates a namespace client for X-Pack APIs

Creates a new instance of the root client

Gets the transport of the client

Creates an asynchronous request that can be awaited

Accepts the HTTP method and relative path to an API, and optional query string and body.

Bulk API

Allows to perform multiple index/update/delete operations in a single request.

Clear Scroll API

Explicitly clears the search context for a scroll.

Close Point In Time API

Close a point in time

Count API

Returns number of documents matching a query.

Create API

Creates a new document in the index.

Returns a 409 response when a document with a same ID already exists in the index.

Delete API

Removes a document from the index.

Delete By Query API

Deletes documents matching the provided query.

Delete By Query Rethrottle API

Changes the number of requests per second for a particular Delete By Query operation.

Delete Script API

Deletes a script.

Exists API

Returns information about whether a document exists in an index.

Exists Source API

Returns information about whether a document source exists in an index.

Explain API

Returns information about why a specific matches (or doesn’t match) a query.

Field Caps API

Returns the information about the capabilities of fields among multiple indices.

Get API

Returns a document.

Get Script API

Returns a script.

Get Script Context API

Returns all script contexts.

Get Script Languages API

Returns available script types, languages and contexts

Get Source API

Returns the source of a document.

Index API

Creates or updates a document in an index.

Info API

Returns basic information about the cluster.

Knn Search API

Performs a kNN search.  

Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Mget API

Allows to get multiple documents in one request.

Msearch API

Allows to execute several search operations in one request.

Msearch Template API

Allows to execute several search template operations in one request.

Mtermvectors API

Returns multiple termvectors in one request.

Open Point In Time API

Open a point in time that can be used in subsequent searches

Ping API

Returns whether the cluster is running.

Put Script API

Creates or updates a script.

Rank Eval API

Allows to evaluate the quality of ranked search results over a set of typical search queries

Reindex API

Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.

Reindex Rethrottle API

Changes the number of requests per second for a particular Reindex operation.

Render Search Template API

Allows to use the Mustache language to pre-render a search definition.

Scripts Painless Execute API

Allows an arbitrary script to be executed and a result to be returned  

Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Scroll API

Allows to retrieve a large numbers of results from a single search request.

Examples

To initiate a scroll, make search API call with a specified scroll timeout, then fetch the next set of hits using the _scroll_id returned in the response. Once no more hits are returned, clear the scroll.

let client = Elasticsearch::default();

fn print_hits(hits: &[Value]) {
    for hit in hits {
        println!(
            "id: '{}', source: '{}', score: '{}'",
            hit["_id"].as_str().unwrap(),
            hit["_source"],
            hit["_score"].as_f64().unwrap()
        );
    }
}

let scroll = "1m";
let mut response = client
    .search(SearchParts::Index(&["tweets"]))
    .scroll(scroll)
    .body(json!({
        "query": {
            "match": {
                "body": {
                    "query": "Elasticsearch rust",
                    "operator": "AND"
                }
            }
        }
    }))
    .send()
    .await?;

let mut response_body = response.json::<Value>().await?;
let mut scroll_id = response_body["_scroll_id"].as_str().unwrap();
let mut hits = response_body["hits"]["hits"].as_array().unwrap();

print_hits(hits);

while hits.len() > 0 {
    response = client
        .scroll(ScrollParts::None)
        .body(json!({
            "scroll": scroll,
            "scroll_id": scroll_id
        }))
        .send()
        .await?;

    response_body = response.json::<Value>().await?;
    scroll_id = response_body["_scroll_id"].as_str().unwrap();
    hits = response_body["hits"]["hits"].as_array().unwrap();
    print_hits(hits);
}

response = client
    .clear_scroll(ClearScrollParts::None)
    .body(json!({
        "scroll_id": scroll_id
    }))
    .send()
    .await?;
    

Search API

Returns results matching a query.

Search Mvt API

Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.  

Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Search Shards API

Returns information about the indices and shards that a search request would be executed against.

Search Template API

Allows to use the Mustache language to pre-render a search definition.

Terms Enum API

The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.

Termvectors API

Returns information and statistics about terms in the fields of a particular document.

Update API

Updates a document with a script or partial document.

Update By Query API

Performs an update on every document in the index without changing the source, for example to pick up a mapping change.

Update By Query Rethrottle API

Changes the number of requests per second for a particular Update By Query operation.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more