Skip to content

Instantly share code, notes, and snippets.

@cuongld2

cuongld2/main.rs

Created Sep 16, 2020
Embed
What would you like to do?
Elasticsearch rust client
use elasticsearch::{http::Method, Elasticsearch, SearchParts};
use http::HeaderMap;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Elasticsearch::default();
let body = b"{\"query\":{\"match_all\":{}}}";
let response = client
.send(
Method::Post,
SearchParts::Index(&["testing"]).url().as_ref(),
HeaderMap::new(),
Option::<&Value>::None,
Some(body.as_ref()),
None,
)
.await;
println!("{:?}", response);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.