elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
695 stars 71 forks source link

[BUG] no method named `and_then` found for struct `elastic::client::requests::document_index::Pending` #102

Closed ronjakoi closed 4 years ago

ronjakoi commented 4 years ago

Describe the bug The documentation describes using the .and_then() method for getting a response object from Elastic, but this method doesn't seem to work as described.

Error message:

error[E0599]: no method named `and_then` found for struct `elastic::client::requests::document_index::Pending` in the current scope
  --> src/main.rs:26:6
   |
26 |     .and_then(|response| response.into_response::<IndexResponse<Value>>());
   |      ^^^^^^^^ method not found in `elastic::client::requests::document_index::Pending`
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
1  | use futures::future::Future;
   |

To Reproduce

use elastic;
use elastic::client::responses::IndexResponse;
use futures::future::Future;
use serde::Serialize;
use serde_json::Value;

#[derive(Serialize)]
struct Stats {
    pub field: String,
}

fn main() {
    let elastic = elastic::client::AsyncClientBuilder::new()
    .static_nodes(vec!["localhost"])
    .build()
    .unwrap();

    let stats = Stats {
        field: "foo".to_string(),
    };
    let index_name = "searches";
    let es_response = elastic
    .document()
    .index_raw(index_name, stats)
    .send()
    .and_then(|response| response.into_response::<IndexResponse<Value>>());
}

Expected behavior The .and_then() method should be available as documented.

Environment (please complete the following information):

Additional context Cargo.toml:

[dependencies]
elastic = "0.21.0-pre.5"
futures = "^0.3"
serde = "^1.0"
serde_json = "^1.0"
russcam commented 4 years ago

Hi @ronjakoi, you have the wrong repository; I think you want elastic-rs/elastic

russcam commented 4 years ago

Thanks @mwilliammyers for opening an issue in elastic-rs/elastic. I'm going to close this one.