Skip to main content

Search

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/opensearch/reference/current/search-search.html

Implementations§

Source

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

Pushes aggregation

Source

pub fn new() -> Search

Creates a default search instance

Source

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

Add runtime mapping to the search request

Source

pub fn script_fields<S, T>(self, name: S, script: T) -> Search
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) -> Search
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) -> Search
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) -> Search
where S: Into<SourceFilter>,

Indicates which source fields are returned for matching documents

Source

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

Specific tag of the request for logging and statistical purposes.

Source

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

Starting document offset.

Defaults to 0.

Source

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

The number of hits to return.

Defaults to 10.

Source

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

Defines the search definition using the Query DSL.

Source

pub fn post_filter<Q>(self, post_filter: Q) -> Search
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) -> Search
where T: IntoIterator, <T as IntoIterator>::Item: Into<Sort>,

A collection of sorting fields

Source

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

Track total hits

Source

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

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

Source

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

Highlight

Source

pub fn rescore<T>(self, rescore: T) -> Search

Rescore

Source

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

Suggest

Source

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

A collection of stored fields

Source

pub fn docvalue_fields<T>(self, docvalue_fields: T) -> Search

A collection of docvalue fields

Source

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

Point in time

Source

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

Search after a set of sort values.

Source

pub fn timeout<T>(self, timeout: T) -> Search
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/opensearch/reference/8.9/search-your-data.html#search-timeout

Source

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

Source

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

Source

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

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());

Trait Implementations§

Source§

fn clone(&self) -> Search

Returns a duplicate 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<(), Error>

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

fn default() -> Search

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

fn deserialize<__D>( __deserializer: __D, ) -> Result<Search, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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 as Serializer>::Ok, <__S as Serializer>::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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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