Using Elastic search high client java client, I was able to search asynchronously
restHighLevelClient.searchAsync(searchRequest, RequestOptions.DEFAULT,new ActionListener() { @Override
public void onResponse(SearchResponse searchResponse) {
But onResponse returns void. How do I make it work with Completablefuture in Java?
I need to collect response from onResponse method and give it to future object
I implemented my own ActionListener which returns my data type. But how do I make it work with Completable Future
Hi Michael,
What is the point of using client.getAsync inside CompletableFuture.supplyAsync lambda when CompletableFuture.supplyAsync would already execute it asynchronously?
Would client.getAsync give you any extra benefits compared to CompletableFuture.supplyAsync(() -> client.get(new GetRequest("index", "id"), RequestOptions.DEFAULT);
?
You are correct, I am not sure why I made the example use the async other than that is what the original poster mentioned in their comment. Your example works the same way as mine but much less complicated, so ++ for that!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.