Struct Search

Source
pub struct Search { /* private fields */ }
Expand description

Returns search hits that match the query defined in the request.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html

Implementations§

Source

pub fn new() -> Self

Creates a default search instance

Source

pub fn runtime_mapping<S>(self, name: S, mapping: RuntimeMapping) -> Self
where S: ToString,

Add runtime mapping to the search request

Source

pub fn script_fields<S, T>(self, name: S, script: T) -> Self
where S: ToString, T: Into<ScriptField>,

Add script fields to the search request

Source

pub fn indices_boost<T, U>(self, field: T, boost: U) -> Self
where T: ToString, U: AsPrimitive<f32>,

Allows to configure different boost level per index when searching across more than one indices. This is very handy when hits coming from one index matter more than hits coming from another index (think social graph where each user has an index).

Source

pub fn min_score<F>(self, min_score: F) -> Self
where F: Into<f32>,

Exclude documents which have a _score less than the minimum specified in min_score

Note, most times, this does not make much sense, but is provided for advanced use cases

Source

pub fn source<S>(self, source: S) -> Self
where S: Into<SourceFilter>,

Indicates which source fields are returned for matching documents

Source

pub fn stats<S>(self, stats: S) -> Self
where S: ToString,

Specific tag of the request for logging and statistical purposes.

Source

pub fn from(self, from: u64) -> Self

Starting document offset.

Defaults to 0.

Source

pub fn size(self, size: u64) -> Self

The number of hits to return.

Defaults to 10.

Source

pub fn query<Q>(self, query: Q) -> Self
where Q: Into<Query>,

Defines the search definition using the Query DSL.

Source

pub fn post_filter<Q>(self, post_filter: Q) -> Self
where Q: Into<Query>,

When you use the post_filter parameter to filter search results, the search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results.

Source

pub fn sort<T>(self, sort: T) -> Self
where T: IntoIterator, T::Item: Into<Sort>,

A collection of sorting fields

Source

pub fn track_total_hits<T>(self, track_total_hits: T) -> Self
where T: Into<TrackTotalHits>,

Track total hits

Source

pub fn track_scores(self, enabled: bool) -> Self

If true, calculate and return document scores, even if the scores are not used for sorting.

Source

pub fn highlight<H>(self, highlight: H) -> Self
where H: Into<Highlight>,

Highlight

Source

pub fn rescore<T>(self, rescore: T) -> Self
where T: IntoIterator, T::Item: Into<Rescore>,

Rescore

Source

pub fn suggest<T, U>(self, name: T, suggester: U) -> Self
where T: ToString, U: Into<Suggester>,

Suggest

Source

pub fn stored_fields<T>(self, stored_fields: T) -> Self
where T: Into<StoredFields>,

A collection of stored fields

Source

pub fn docvalue_fields<T>(self, docvalue_fields: T) -> Self
where T: IntoIterator, T::Item: ToString,

A collection of docvalue fields

Source

pub fn pit(self, pit: PointInTime) -> Self

Point in time

Source

pub fn search_after<T>(self, sort_values: T) -> Self
where T: Into<Terms>,

Search after a set of sort values.

Source

pub fn timeout<T>(self, timeout: T) -> Self
where T: Into<Time>,

parameter to specify a duration you’d like to wait on each shard to complete.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html#search-timeout

Source

pub fn knn(self, knn: Knn) -> Self

Source

pub fn collapse<C>(self, collapse: C) -> Self
where C: Into<Collapse>,

Source

pub fn extra(self, extra: BTreeMap<String, Value>) -> Self

Extra fields for something not yet supported.

Search::new()
    .size(10)
    .extra([
        (
            "knn".to_owned(),
            json!({ "field": "abc" }),
        ),
        (
            "terminate_after".to_owned(),
            json!(42)
        ),
    ].into());
Source

pub fn aggregate<N, A>(self, aggregation_name: N, aggregation: A) -> Self

Pushes aggregation

Trait Implementations§

Source§

fn clone(&self) -> Search

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn default() -> Search

Returns the “default value” for a type. Read more
Source§

fn eq(&self, other: &Search) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.