Struct rs_es::Client
[−]
[src]
pub struct Client { // some fields omitted }
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 hostname and port need 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::new("localhost", 9200); let result = client.search_uri() .with_indexes(&["index_name"]) .with_query("field:value") .send();
See the specific operations and their builder objects for details.
Methods
impl Client
fn new(host: &str, port: u32) -> Client
Create a new client
fn full_url(&self, suffix: &str) -> String
Take a nearly complete ElasticSearch URL, and stick the host/port part on the front.
fn version(&mut self) -> Result<String, EsError>
Calls the base ES path, returning the version number
fn refresh<'a>(&'a mut self) -> RefreshOperation
fn index<'a, 'b, E: Encodable>(&'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
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
fn delete<'a>(&'a mut self, index: &'a str, doc_type: &'a str, id: &'a str) -> DeleteOperation
fn delete_by_query<'a>(&'a mut self) -> DeleteByQueryOperation
Delete by query
See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/docs-delete-by-query.html
Warning: will be removed in ElasticSearch 2.0
fn bulk<'a, 'b>(&'a mut self, actions: &'b [Action]) -> BulkOperation<'a, 'b>
fn analyze<'a>(&'a mut self, body: &'a str) -> AnalyzeOperation
fn search_uri<'a>(&'a mut self) -> SearchURIOperation
Search via the query parameter
See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-uri-request.html
fn search_query<'a>(&'a mut self) -> SearchQueryOperation
Search via the query DSL
See: https://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-request-body.html