Member-only story

Elasticsearch

Elasticsearch client for Rust

This is an example for interact to Elasticsearch in Rust.

Donald Le

--

Photo by Guilherme Stecanella on Unsplash

Cargo.toml

[package]
name = "rust-getstarted"
version = "0.1.0"
authors = ["cuongld2 <ledinhcuong99@gmail.com>"]
edition = "2018"
reqwest = "0.10.8"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["full"] }
hyper = "0.13.5"
error-chain = "0.12.4"
elastic = "*"
elastic_derive = "*"
elasticsearch = "7.9.0-alpha.1"
http = "*"
serde_json = "*"
futures = "*"

ElasticSearch query data

Postman query data from elasticsearch

main.rs

Running this will print these to console

Ok(Response { method: Post, url: "http://localhost:9200/testing/_search", status_code: 200, headers: {"content-type": "application/json; charset=UTF-8"} })

That’s it.

Hope it helps guys.

~~PEACE~~

--

--

No responses yet