extern crate serde_json;
extern crate elastic;
use serde_json::Value;
use elastic::error::*;
use elastic::prelude::*;
fn main() {
let client = Client::new(RequestParams::default()).unwrap();
let res = client
.get_document::<Value>(index("typed_sample_index"), id("1"))
.ty("mytype")
.send();
match res {
Ok(GetResponse { source: Some(doc), .. }) => {
println!("document found: {:?}", doc);
}
Ok(_) => {
println!("document not found, but index exists");
}
Err(e) => {
match *e.kind() {
ErrorKind::Api(ApiError::IndexNotFound { .. }) => {
println!("index not found");
}
_ => panic!(e),
}
}
}
}