elastic_* is an ecosystem of community crates for interacting with Elasticsearch from Rust.
The API is targetting Elastic 5.x.
Crate functionality covers:
Quick reference:
To provide a strongly-typed, full-featured and efficient Elasticsearch client for Rust over (eventually) asynchronous io. Rust gives us a lot of tools for building super-performant but highly accessible libraries, which we aim to continue.
The REST API is provided by an inline JSON macro so it's efficient and always in line with whatever version of Elasticsearch you're targeting. This means you don't need to learn another API for interacting with Elasticsearch; queries mocked in Sense can just be copy+pasted into your Rust code.
The core focus of this project is on strong typing over your document types and query responses in Elasticsearch, rather than trying to map the entire Query DSL.
Support for Elastic's plugin products, like watcher and graph could be added as feature-gated modules in the elastic_hyper and elastic_rotor clients and elastic_types as necessary.
If you'd like to use a strongly-typed Query DSL builder see rs-es. This client does the hard work of providing an idiomatic Rust API for interacting with Elasticsearch. It has the advantage of letting you know your queries will parse at compile-time instead of runtime.
See the examples folder.
Add elastic and json_str to your Cargo.toml:
```toml [dependencies] elastic = "*"
json_str = "*" ```
Get a client instance and request parameters:
```rust
extern crate json_str; extern crate elastic;
use elastic::client;
let (client, params) = client::default().unwrap(); ```
Create a search request:
```rust let body = jsonstr!({ query: { querystring: { query: "*" } } });
let req = client::SearchRequest::forindex("all", body); ```
Send the request and iterate through the returned hits:
```rust let res: client::Response = client .elastic_req(¶ms, req).unwrap() .json().unwrap();
for hit in res.hits() { println!("{:?}", hit); } ```
Development is active, but because functionality is split across crates it can be hard to track where the effort is going. There is a GitHub Project to easily track priorities at the crate-level.
elastic_reqwestelastic_hyper provides a synchronous hyper implementation of the Elasticsearch REST API.
This crate lives in the elastic_hyper repo.
elastic_typeselastic_types is a library for building Elasticsearch types in Rust. Define your Elasticsearch types as PORS (Plain Old Rust Structures) and generate an equivalent Elasticsearch mapping from them, where correctness is enforced by Rust's type system.
This crate lives in the elastic_types repo.
elastic_rotorelastic_rotor is an experimental REST API client that handles a single specific usecase: high throughput.