Struct OpenSearch

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

Root client for top level APIs

Implementations§

Source§

impl OpenSearch

Source

pub fn cat(&self) -> Cat<'_>

Creates a namespace client for Cat APIs

Source§

impl OpenSearch

Source

pub fn cluster(&self) -> Cluster<'_>

Creates a namespace client for Cluster APIs

Source§

impl OpenSearch

Source

pub fn dangling_indices(&self) -> DanglingIndices<'_>

Creates a namespace client for DanglingIndices APIs

Source§

impl OpenSearch

Source

pub fn indices(&self) -> Indices<'_>

Creates a namespace client for Indices APIs

Source§

impl OpenSearch

Source

pub fn ingest(&self) -> Ingest<'_>

Creates a namespace client for Ingest APIs

Source§

impl OpenSearch

Source

pub fn nodes(&self) -> Nodes<'_>

Creates a namespace client for Nodes APIs

Source§

impl OpenSearch

Source

pub fn snapshot(&self) -> Snapshot<'_>

Creates a namespace client for Snapshot APIs

Source§

impl OpenSearch

Source

pub fn tasks(&self) -> Tasks<'_>

Creates a namespace client for Tasks APIs

Source§

impl OpenSearch

Source

pub fn text_structure(&self) -> TextStructure<'_>

Creates a namespace client for TextStructure APIs

Source§

impl OpenSearch

Source

pub fn new(transport: Transport) -> Self

Creates a new instance of the root client

Source

pub fn transport(&self) -> &Transport

Gets the transport of the client

Source

pub async fn send<B, Q>( &self, method: Method, path: &str, headers: HeaderMap, query_string: Option<&Q>, body: Option<B>, timeout: Option<Duration>, ) -> Result<Response, Error>
where B: Body, Q: Serialize + ?Sized,

Creates an asynchronous request that can be awaited

Accepts the HTTP method and relative path to an API, and optional query string and body.

Source§

impl OpenSearch

Source

pub fn bulk<'a, 'b>(&'a self, parts: BulkParts<'b>) -> Bulk<'a, 'b, ()>

Bulk API

Allows to perform multiple index/update/delete operations in a single request.

Source

pub fn clear_scroll<'a, 'b>( &'a self, parts: ClearScrollParts<'b>, ) -> ClearScroll<'a, 'b, ()>

Clear Scroll API

Explicitly clears the search context for a scroll.

Source

pub fn close_point_in_time<'a, 'b>(&'a self) -> ClosePointInTime<'a, 'b, ()>

Close Point In Time API

Close a point in time

Source

pub fn count<'a, 'b>(&'a self, parts: CountParts<'b>) -> Count<'a, 'b, ()>

Count API

Returns number of documents matching a query.

Source

pub fn create<'a, 'b>(&'a self, parts: CreateParts<'b>) -> Create<'a, 'b, ()>

Create API

Creates a new document in the index.

Returns a 409 response when a document with a same ID already exists in the index.

Source

pub fn delete<'a, 'b>(&'a self, parts: DeleteParts<'b>) -> Delete<'a, 'b>

Delete API

Removes a document from the index.

Source

pub fn delete_by_query<'a, 'b>( &'a self, parts: DeleteByQueryParts<'b>, ) -> DeleteByQuery<'a, 'b, ()>

Delete By Query API

Deletes documents matching the provided query.

Source

pub fn delete_by_query_rethrottle<'a, 'b>( &'a self, parts: DeleteByQueryRethrottleParts<'b>, ) -> DeleteByQueryRethrottle<'a, 'b, ()>

Delete By Query Rethrottle API

Changes the number of requests per second for a particular Delete By Query operation.

Source

pub fn delete_script<'a, 'b>( &'a self, parts: DeleteScriptParts<'b>, ) -> DeleteScript<'a, 'b>

Delete Script API

Deletes a script.

Source

pub fn exists<'a, 'b>(&'a self, parts: ExistsParts<'b>) -> Exists<'a, 'b>

Exists API

Returns information about whether a document exists in an index.

Source

pub fn exists_source<'a, 'b>( &'a self, parts: ExistsSourceParts<'b>, ) -> ExistsSource<'a, 'b>

Exists Source API

Returns information about whether a document source exists in an index.

Source

pub fn explain<'a, 'b>(&'a self, parts: ExplainParts<'b>) -> Explain<'a, 'b, ()>

Explain API

Returns information about why a specific matches (or doesn’t match) a query.

Source

pub fn field_caps<'a, 'b>( &'a self, parts: FieldCapsParts<'b>, ) -> FieldCaps<'a, 'b, ()>

Field Caps API

Returns the information about the capabilities of fields among multiple indices.

Source

pub fn get<'a, 'b>(&'a self, parts: GetParts<'b>) -> Get<'a, 'b>

Get API

Returns a document.

Source

pub fn get_script<'a, 'b>( &'a self, parts: GetScriptParts<'b>, ) -> GetScript<'a, 'b>

Get Script API

Returns a script.

Source

pub fn get_script_context<'a, 'b>(&'a self) -> GetScriptContext<'a, 'b>

Get Script Context API

Returns all script contexts.  

§Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Source

pub fn get_script_languages<'a, 'b>(&'a self) -> GetScriptLanguages<'a, 'b>

Get Script Languages API

Returns available script types, languages and contexts  

§Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Source

pub fn get_source<'a, 'b>( &'a self, parts: GetSourceParts<'b>, ) -> GetSource<'a, 'b>

Get Source API

Returns the source of a document.

Source

pub fn index<'a, 'b>(&'a self, parts: IndexParts<'b>) -> Index<'a, 'b, ()>

Index API

Creates or updates a document in an index.

Source

pub fn info<'a, 'b>(&'a self) -> Info<'a, 'b>

Info API

Returns basic information about the cluster.

Source

pub fn mget<'a, 'b>(&'a self, parts: MgetParts<'b>) -> Mget<'a, 'b, ()>

Mget API

Allows to get multiple documents in one request.

Source

pub fn msearch<'a, 'b>(&'a self, parts: MsearchParts<'b>) -> Msearch<'a, 'b, ()>

Msearch API

Allows to execute several search operations in one request.

Source

pub fn msearch_template<'a, 'b>( &'a self, parts: MsearchTemplateParts<'b>, ) -> MsearchTemplate<'a, 'b, ()>

Msearch Template API

Allows to execute several search template operations in one request.

Source

pub fn mtermvectors<'a, 'b>( &'a self, parts: MtermvectorsParts<'b>, ) -> Mtermvectors<'a, 'b, ()>

Mtermvectors API

Returns multiple termvectors in one request.

Source

pub fn open_point_in_time<'a, 'b>( &'a self, parts: OpenPointInTimeParts<'b>, ) -> OpenPointInTime<'a, 'b, ()>

Open Point In Time API

Open a point in time that can be used in subsequent searches

Source

pub fn ping<'a, 'b>(&'a self) -> Ping<'a, 'b>

Ping API

Returns whether the cluster is running.

Source

pub fn put_script<'a, 'b>( &'a self, parts: PutScriptParts<'b>, ) -> PutScript<'a, 'b, ()>

Put Script API

Creates or updates a script.

Source

pub fn rank_eval<'a, 'b>( &'a self, parts: RankEvalParts<'b>, ) -> RankEval<'a, 'b, ()>

Rank Eval API

Allows to evaluate the quality of ranked search results over a set of typical search queries  

§Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Source

pub fn reindex<'a, 'b>(&'a self) -> Reindex<'a, 'b, ()>

Reindex API

Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.

Source

pub fn reindex_rethrottle<'a, 'b>( &'a self, parts: ReindexRethrottleParts<'b>, ) -> ReindexRethrottle<'a, 'b, ()>

Reindex Rethrottle API

Changes the number of requests per second for a particular Reindex operation.

Source

pub fn render_search_template<'a, 'b>( &'a self, parts: RenderSearchTemplateParts<'b>, ) -> RenderSearchTemplate<'a, 'b, ()>

Render Search Template API

Allows to use the Mustache language to pre-render a search definition.

Source

pub fn scripts_painless_execute<'a, 'b>( &'a self, ) -> ScriptsPainlessExecute<'a, 'b, ()>

Scripts Painless Execute API

Allows an arbitrary script to be executed and a result to be returned  

§Optional, experimental

This requires the experimental-apis feature. Can have breaking changes in future versions or might even be removed entirely.

Source

pub fn scroll<'a, 'b>(&'a self, parts: ScrollParts<'b>) -> Scroll<'a, 'b, ()>

Scroll API

Allows to retrieve a large numbers of results from a single search request.

§Examples

To initiate a scroll, make search API call with a specified scroll timeout, then fetch the next set of hits using the _scroll_id returned in the response. Once no more hits are returned, clear the scroll.

let client = OpenSearch::default();

fn print_hits(hits: &[Value]) {
    for hit in hits {
        println!(
            "id: '{}', source: '{}', score: '{}'",
            hit["_id"].as_str().unwrap(),
            hit["_source"],
            hit["_score"].as_f64().unwrap()
        );
    }
}

let scroll = "1m";
let mut response = client
    .search(SearchParts::Index(&["tweets"]))
    .scroll(scroll)
    .body(json!({
        "query": {
            "match": {
                "body": {
                    "query": "OpenSearch rust",
                    "operator": "AND"
                }
            }
        }
    }))
    .send()
    .await?;

let mut response_body = response.json::<Value>().await?;
let mut scroll_id = response_body["_scroll_id"].as_str().unwrap();
let mut hits = response_body["hits"]["hits"].as_array().unwrap();

print_hits(hits);

while hits.len() > 0 {
    response = client
        .scroll(ScrollParts::None)
        .body(json!({
            "scroll": scroll,
            "scroll_id": scroll_id
        }))
        .send()
        .await?;

    response_body = response.json::<Value>().await?;
    scroll_id = response_body["_scroll_id"].as_str().unwrap();
    hits = response_body["hits"]["hits"].as_array().unwrap();
    print_hits(hits);
}

response = client
    .clear_scroll(ClearScrollParts::None)
    .body(json!({
        "scroll_id": scroll_id
    }))
    .send()
    .await?;
    
Source

pub fn search<'a, 'b>(&'a self, parts: SearchParts<'b>) -> Search<'a, 'b, ()>

Search API

Returns results matching a query.

Source

pub fn search_shards<'a, 'b>( &'a self, parts: SearchShardsParts<'b>, ) -> SearchShards<'a, 'b, ()>

Search Shards API

Returns information about the indices and shards that a search request would be executed against.

Source

pub fn search_template<'a, 'b>( &'a self, parts: SearchTemplateParts<'b>, ) -> SearchTemplate<'a, 'b, ()>

Search Template API

Allows to use the Mustache language to pre-render a search definition.

Source

pub fn termvectors<'a, 'b>( &'a self, parts: TermvectorsParts<'b>, ) -> Termvectors<'a, 'b, ()>

Termvectors API

Returns information and statistics about terms in the fields of a particular document.

Source

pub fn update<'a, 'b>(&'a self, parts: UpdateParts<'b>) -> Update<'a, 'b, ()>

Update API

Updates a document with a script or partial document.

Source

pub fn update_by_query<'a, 'b>( &'a self, parts: UpdateByQueryParts<'b>, ) -> UpdateByQuery<'a, 'b, ()>

Update By Query API

Performs an update on every document in the index without changing the source, for example to pick up a mapping change.

Source

pub fn update_by_query_rethrottle<'a, 'b>( &'a self, parts: UpdateByQueryRethrottleParts<'b>, ) -> UpdateByQueryRethrottle<'a, 'b, ()>

Update By Query Rethrottle API

Changes the number of requests per second for a particular Update By Query operation.

Trait Implementations§

Source§

impl Clone for OpenSearch

Source§

fn clone(&self) -> OpenSearch

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§

impl Debug for OpenSearch

Source§

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

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

impl Default for OpenSearch

Source§

fn default() -> OpenSearch

Returns the “default value” for a type. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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<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> ErasedDestructor for T
where T: 'static,