extern crate elastic;
extern crate env_logger;
use std::error::Error;
use std::io::Read;
use elastic::prelude::*;
fn run() -> Result<(), Box<Error>> {
let client = SyncClientBuilder::new()
.params(|p| p.url_param("pretty", true))
.build()?;
let req = SearchRequest::for_index("_all", r#"{ "query": { "match_all": {} } }"#);
let mut res = client.request(req).send()?.into_raw();
match res.status() {
200...299 => (),
status => panic!("error: {:?}", status),
}
let mut body = String::new();
res.read_to_string(&mut body)?;
println!("{}", body);
Ok(())
}
fn main() {
env_logger::init().unwrap();
run().unwrap()
}