# actix-elastic
## Installation
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"
```
## Get started
1. Create an elastic actix actor
```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"
```rust
use actix_web::HttpResponse;
match addr.send(EsCmd::ScrollBytes("example_index_1", json!({
"query": {
"match_all": {}
}
}))).await?? {
EsResult::ScrollBytes(stream) => Ok(HttpResponse::Ok().content_type("application/json").streaming_response(stream)),
_ => unreachable!()
}
```
4. Scroll Deserialized Items
```rust
match addr.send(EsCmd::ScrollItems("example_index_1", json!({
"query": {
"match_all": {}
}
}))).await?? {
EsResult::ScrollItems(mut stream) => {
while let Some(hits) = stream.next().await {
println!("{:?}", hits.len());
}
},
_ => unreachable!()
}
```