ElasticSearch Java API的异步性质 [英] Async nature of ElasticSearch Java API

查看:188
本文介绍了ElasticSearch Java API的异步性质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想为elasticSearch服务编写集成测试:

1.索引

2.搜索

3.检查结果

Wanna write integration tests for elasticSearch service:
1. Index
2. Search
3. Check result

每个Java api方法都是异步执行的。如何使其成为简单的同步api:调用 api.a ,等待结果,调用 api.b 等待结果...

Each Java api method is executed asynchronously. How can I make it as simple sync api: call api.a, waiting for result, call api.b, waiting for result...

推荐答案

正如@loteq所说,你可以简单地调用 .actionGet() 未来上使其同步。检查弹性搜索集成测试,他们有一些非常好的例子。

As @loteq mentioned, you can simply call .actionGet() on a Future to make it synchronous. Check elasticsearch integration tests, they have some very good examples.

这篇关于ElasticSearch Java API的异步性质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆