elastic_reqwest 
Provides a no-fuss, synchronous reqwest implementation of the Elasticsearch REST API. The reqwest client is simple to use; there's basically no setup needed besides creating a reqwest::Client object to use for requests. The reqwest client is general-purpose and suitable for any scenario where on-demand requests are sufficient. It also splits the request process into a few logical methods that could be easily split across asynchronous boundaries.
This library is the HTTP backend for the higher-level elastic client.
Example
The elastic_reqwest client is a thin layer over reqwest; it just maps functions to routes. It's up to the caller to serialise and deserialise HTTP content.
- For query serialisation, the
json_strcrate provides thejson_str!macro for creating ad-hoc API queries. - For type serialisation / deserialisation, see
elastic_types.
Currently targeting the master Elasticsearch branch, aiming for 5.x.
This will be stabilised through features in the future.
Add elastic_reqwest and json_str to your Cargo.toml:
[dependencies]
elastic_reqwest = "*"
reqwest = "*"
# Optional for request bodies
json_str = "*"
Ping the availability of your cluster:
extern crate elastic_reqwest as cli;
extern crate reqwest;
use ;
use PingRequest;
use PingResponse;
let = default.unwrap;
let http_res = client.elastic_req.unwrap;
let parse_res = .from_response.unwrap;
Customise the location of the Elasticsearch cluster:
let = default;
params.base_url = Stringfrom;
A query DSL query:
extern crate json_str;
extern crate elastic_reqwest as cli;
extern crate reqwest;
use ;
use SearchRequest;
use SearchResponse;
let = default.unwrap;
let search = ;
let http_res = client.elastic_req.unwrap;
let search_res = .from_response.unwrap;