ANNOUNCE: Rust API Client

Hi All!

I've been working on an Elasticsearch REST API client in the Rust Language for a while and wanted to share my results so far.

See:

The goal is to provide a modular ecosystem of libraries for interacting with Elasticsearch in Rust, so you can choose how fat you want your client code to be. Rust is a high-performance language that lets you get as close to the metal as you want (but also safe, so it's great for those of us who've never had to manage their own pointers before). That means you can achieve fast, safe and easy to maintain code without sacrificing expressiveness.

All querying can be done through a json-parsing macro, so I don't need to spend time keeping the implementation in sync with the API.

A quick sample for calling POST: /_search:

let (mut client, params) = elastic::default();

let response = elastic::search::post(
    &mut client, &params,
    json_lit!({
        query: {
            query_string: {
                query: "*"
            }
        }
    })
).unwrap();

I've also got a working (still WIP though) implementation of the core datatypes that can be used to generate a valid mapping:

#[derive(Serialize, Deserialize, ElasticType)]
pub struct MyType {
    pub my_date: ElasticDate<EpochMillis>,
    pub my_string: String,
    pub my_num: i32
}

Which produces the following mapping json:

{
  "properties": {
    "my_date": {
      "type": "date",
      "format": "epoch_millis"
    },
    "my_string": {
      "type": "string"
    },
    "my_num": {
      "type": "integer"
    }
  }
}

See:

I'd like to be able to provide an official-quality suite of tools for Elasticsearch from Rust, so feedback from the community would be really helpful!

3 Likes