Add this package to Cargo.toml
of your project. (Check https://crates.io/crates/actix-elastic for right version)
toml
[dependencies]
actix = "0.10.0"
actix-elastic = "1.0.0"
```rust use actix::{Arbiter, Addr, Supervisor}; use actix_elastic::{EsClient, EsCmd, EsResult};
let arb = Arbiter::new(); let elastic_url = "http://127.0.0.1:9200"
let addr: Addr
```rust use serde_json::json;
addr.send(EsCmd::Index("exampleindex1", ("id_1", CustomType))).await??;
addr.send(EsCmd::Search("exampleindex1", json!({ "query": { "match_all": {} } })).await??;
addr.send(EsCmd::DeleteByQuery("exampleindex1", json!({ "query": { "bool": { "must": [ { "match_phase": { "name": "alice" } } ] } } }))).await??; ```
```rust use actix_web::HttpResponse;
match addr.send(EsCmd::ScrollHits("exampleindex1", json!({ "query": { "matchall": {} } }))).await?? { EsResult::ScrollHits(stream) => Ok(HttpResponse::Ok().contenttype("application/json").streaming_response(stream)), _ => unreachable!() } ```