Struct elastic_responses::search::SearchResponse
[−]
[src]
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:
- Only metric aggregations nested in buckets are supported
- Only Simple Metric Aggregations like
avg
,min
,max
,sum
and Stats Aggregations are supported
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>
[src]
fn took(&self) -> u64
Time in milliseconds it took for Elasticsearch to process the request.
fn timed_out(&self) -> bool
Whether or not the request timed out before completing.
Shards metadata for the request.
fn status(&self) -> Option<u16>
A http status associated with the response.
fn total(&self) -> u64
The total number of documents that matched the search query.
fn max_score(&self) -> Option<f32>
The max score for documents that matched the search query.
fn hits(&self) -> Hits<T>
Iterate over the hits matched by the search query.
fn into_hits(self) -> IntoHits<T>
Convert the response into an iterator that consumes the hits.
fn documents(&self) -> Documents<T>
Iterate over the documents matched by the search query.
This iterator emits just the _source
field for the returned hits.
fn into_documents(self) -> IntoDocuments<T>
Convert the response into an iterator that consumes the documents.
fn aggs(&self) -> Aggs
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.
Trait Implementations
impl<T: Debug> Debug for SearchResponse<T>
[src]
impl<T: DeserializeOwned> IsOk for SearchResponse<T>
[src]
fn is_ok<B: ResponseBody>(
head: HttpResponseHead,
body: Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseResponseError>
head: HttpResponseHead,
body: Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseResponseError>
Inspect the http response to determine whether or not it succeeded.