elastic icon indicating copy to clipboard operation
elastic copied to clipboard

elastic::client::requests::document_index::Pending does not have method then()

Open ronjakoi opened this issue 4 years ago • 2 comments

My code starting on line 169:

let es = elastic::client::AsyncClientBuilder::new()
    .static_nodes(backend_url)
    .build()
    .unwrap(); // TODO
let timestamp = Utc::now();
let stats = Stats {
    core: "helsinki.fi".to_string(),
    status: res.response().status().as_u16(),
    query_time: entry_time.elapsed().whole_milliseconds(),
    timestamp: timestamp
        .format("%Y-%m-%d %H:%M:%S%.6f%:z")
        .to_string(),
    // TODO: remove stopwords
    original_query: clean_and_split_query(&q.1),
    query: clean_and_split_query(&q.1),
    stopword_count: 0,
    removed_stopwords: vec![],
};
let index_name = format!("searches-{}", timestamp.format("%Y%m%d"));
let send_fut = es.document().index_raw(index_name, stats).send();
send_fut.then(|_| ());

My error message:

   --> src/logging.rs:189:34
    |
189 |                         send_fut.then(|_| Ok(()));
    |                                  ^^^^ method not found in `elastic::client::requests::document_index::Pending`
    |
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use futures::future::Future;`

I do have this use line in my file:

use futures::future::{ok, Ready, Future};

ronjakoi avatar Apr 23 '20 10:04 ronjakoi

My elastic library version is 0.21.0-pre.5.

ronjakoi avatar Apr 23 '20 10:04 ronjakoi

Sorry for the late response.

It looks like from your other issue, https://github.com/elastic/elasticsearch-rs/issues/102, you are using futures v0.3.0.

This repo is not compatible with futures v0.3 and we don't plan to support it as we have moved our development efforts over to the official crate which does support futures v0.3 (async/await syntax etc).

If you need to stick with this crate, you can try using tokio-compat or futures 0.1, but it might end up being more work than migrating over to the official client...

mwilliammyers avatar May 29 '20 19:05 mwilliammyers