Struct Client

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

The core of the ElasticSearch client, owns a HTTP connection.

Each instance of Client is reusable, but only one thread can use each one at once. This will be enforced by the borrow-checker as most methods are defined on &mut self.

To create a Client, the URL needs to be specified.

Each ElasticSearch API operation is defined as a method on Client. Any compulsory parameters must be given as arguments to this method. It returns an operation builder that can be used to add any optional parameters.

Finally send is called to submit the operation:

§Examples

use rs_es::Client;

let mut client = Client::init("http://localhost:9200");

See the specific operations and their builder objects for details.

Implementations§

Source§

impl Client

Source

pub fn analyze<'a>(&'a mut self, body: &'a str) -> AnalyzeOperation<'_, '_>

Analyze

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html

Source§

impl Client

Source

pub fn bulk<'a, 'b, S>( &'a mut self, actions: &'b [Action<S>], ) -> BulkOperation<'a, 'b, S>
where S: Serialize,

Bulk

See: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

Source§

impl Client

Source

pub fn delete<'a>( &'a mut self, index: &'a str, doc_type: &'a str, id: &'a str, ) -> DeleteOperation<'_, '_>

Delete by ID

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/docs-delete.html

Source§

impl Client

Source

pub fn delete_index<'a>( &'a mut self, index: &'a str, ) -> Result<GenericResult, EsError>

Delete given index

TODO: ensure all options are supported, replace with a DeleteIndexOperation to follow the pattern defined elsewhere.

See: https://www.elastic.co/guide/en/elasticsearch/reference/2.x/indices-delete-index.html

Source§

impl Client

Source

pub fn get<'a>( &'a mut self, index: &'a str, id: &'a str, ) -> GetOperation<'_, '_>

Implementation of the ES GET API

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/docs-get.html

Source§

impl Client

Source

pub fn index<'a, 'b, E: Serialize>( &'a mut self, index: &'b str, doc_type: &'b str, ) -> IndexOperation<'a, 'b, E>

An index operation to index a document in the specified index.

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/docs-index_.html

Source§

impl Client

Source

pub fn open_index<'a>( &'a mut self, index: &'a str, ) -> Result<GenericResult, EsError>

Open the index, making it available.

Source

pub fn close_index<'a>( &'a mut self, index: &'a str, ) -> Result<GenericResult, EsError>

Close the index, making it unavailable and modifiable.

Source

pub fn wait_for_status<'a>( &'a mut self, status: &'a str, timeout: &'a str, ) -> Result<(), EsError>

TODO: Return proper health data from https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html

Source§

impl Client

Source

pub fn refresh(&mut self) -> RefreshOperation<'_, '_>

Refresh

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/indices-refresh.html

Source§

impl Client

Source

pub fn count_uri(&mut self) -> CountURIOperation<'_, '_>

Count via the query parameter

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-uri-request.html

Source

pub fn count_query(&mut self) -> CountQueryOperation<'_, '_>

Count via the query DSL

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-body.html

Source§

impl Client

Source

pub fn search_uri(&mut self) -> SearchURIOperation<'_, '_>

Search via the query parameter

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-uri-request.html

Source

pub fn search_query(&mut self) -> SearchQueryOperation<'_, '_>

Search via the query DSL

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-body.html

Source§

impl Client

Source

pub fn version(&mut self) -> VersionOperation<'_>

Calls the base ES path, returning the version number

Source§

impl Client

Source

pub fn init(url_s: &str) -> Result<Client, UrlError>

Create a new client

Source

pub fn init_with_timeout( url_s: &str, timeout: Option<Duration>, ) -> Result<Client, UrlError>

Source

pub fn full_url(&self, suffix: &str) -> Url

Take a nearly complete ElasticSearch URL, and stick the URL on the front.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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 Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,