Is this right way to do elasticsearch login with rust

extern crate serde_json;
use elasticsearch::{
    http::transport::{SingleNodeConnectionPool, Transport, TransportBuilder},
    Elasticsearch, Error, IndexParts, SearchParts,
use futures::executor::block_on;
use serde_json::Value;
use url::Url;
async fn main() -> Result<(), Error> {
    let credentials = Credentials::Basic("<username>".into(), "<password>".into());
    let u = Url::parse("http://localhost:9200")?;
    let conn_pool = SingleNodeConnectionPool::new(u);
    let transport = TransportBuilder::new(conn_pool).auth(credentials).build()?;
    let client = Elasticsearch::new(transport);
    let response = client
            "query": {
                "match": {
                    "message": "Elasticsearch rust"
    let response_body = response.read_body::<Value>().await?;
    println!("{:?}", response_body);

This looks correct, except that

let response_body = response.read_body::<Value>().await?;

is now

let response_body = response.json::<Value>().await?;

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.