[−][src]Struct elastic_responses::search::SearchResponse
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]
pub fn took(&self) -> u64
[src]
Time in milliseconds it took for Elasticsearch to process the request.
pub fn timed_out(&self) -> bool
[src]
Whether or not the request timed out before completing.
pub fn shards(&self) -> &Shards
[src]
Shards metadata for the request.
pub fn status(&self) -> Option<u16>
[src]
A http status associated with the response.
pub fn total(&self) -> u64
[src]
The total number of documents that matched the search query.
pub fn max_score(&self) -> Option<f32>
[src]
The max score for documents that matched the search query.
ⓘImportant traits for Hits<'a, T>pub fn hits(&self) -> Hits<T>
[src]
Iterate over the hits matched by the search query.
ⓘImportant traits for IntoHits<T>pub fn into_hits(self) -> IntoHits<T>
[src]
Convert the response into an iterator that consumes the hits.
ⓘImportant traits for Documents<'a, T>pub fn documents(&self) -> Documents<T>
[src]
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>pub fn into_documents(self) -> IntoDocuments<T>
[src]
Convert the response into an iterator that consumes the documents.
ⓘImportant traits for Aggs<'a>pub fn aggs(&self) -> Aggs
[src]
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.
pub fn aggs_raw(&self) -> Option<&Value>
[src]
Get a reference to the raw aggregation value.
Trait Implementations
impl<T: DeserializeOwned> IsOkOnSuccess for SearchResponse<T>
[src]
impl<T: Debug> Debug for SearchResponse<T>
[src]
impl<'de, T> Deserialize<'de> for SearchResponse<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<T> Send for SearchResponse<T> where
T: Send,
T: Send,
impl<T> Sync for SearchResponse<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T> IsOk for T where
T: IsOkOnSuccess,
[src]
T: IsOkOnSuccess,
fn is_ok<B>(
HttpResponseHead,
Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseError> where
B: ResponseBody,
[src]
HttpResponseHead,
Unbuffered<B>
) -> Result<MaybeOkResponse<B>, ParseError> where
B: ResponseBody,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,