#[macro_use]
extern crate elastic_derive;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate elastic;
use elastic::prelude::*;
#[derive(Debug, Serialize, Deserialize, ElasticType)]
struct MyType {
id: i32,
title: String,
timestamp: Date<DefaultDateFormat>,
}
fn main() {
let client = Client::new(RequestParams::default()).unwrap();
let doc = MyType {
id: 1,
title: String::from("A title"),
timestamp: Date::now(),
};
client.create_index(sample_index()).send().unwrap();
client.put_mapping::<MyType>(sample_index()).send().unwrap();
client
.index_document(sample_index(), id(doc.id), doc)
.send()
.unwrap();
}
fn sample_index() -> Index<'static> {
Index::from("index_sample_index")
}