Struct elastic::client::responses::prelude::SearchResponse []

pub struct SearchResponse<T> { /* fields omitted */ }

Response for a search request.

This is the main struct of the crate, provides access to the hits and aggs iterators.

Aggregations

Aggregations currently have the following limitations:

Examples

Iterate over the hits in a search response:

let response: SearchResponse<Value> = do_request();

// Iterate over hits. Could also use `documents`
for hit in response.hits() {
    let score = hit.score().unwrap_or(f32::default());
    let doc = hit.document();
    
    println!("score: {}", score);
    println!("doc: {:?}", doc);
}

Methods

impl<T> SearchResponse<T>

Time in milliseconds it took for Elasticsearch to process the request.

Whether or not the request timed out before completing.

Shards metadata for the request.

A http status associated with the response.

The total number of documents that matched the search query.

The max score for documents that matched the search query.

Important traits for Hits<'a, T>

Iterate over the hits matched by the search query.

Important traits for IntoHits<T>

Convert the response into an iterator that consumes the hits.

Important traits for Documents<'a, T>

Iterate over the documents matched by the search query.

This iterator emits just the _source field for the returned hits.

Important traits for IntoDocuments<T>

Convert the response into an iterator that consumes the documents.

Important traits for Aggs<'a>

Iterate over the aggregations in the response.

This Iterator transforms the tree-like JSON object into a row/table based format for use with standard iterator adaptors.

Get a reference to the raw aggregation value.

Trait Implementations

impl<T> IsOk for SearchResponse<T> where
    T: DeserializeOwned

Inspect the http response to determine whether or not it succeeded.

impl<'de, T> Deserialize<'de> for SearchResponse<T> where
    T: Deserialize<'de>, 

Deserialize this value from the given Serde deserializer. Read more

impl<T> Debug for SearchResponse<T> where
    T: Debug

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for SearchResponse<T> where
    T: Send

impl<T> Sync for SearchResponse<T> where
    T: Sync