92.6. 索引示例

以下是一个简单的 INDEX 示例

from("direct:index")
.to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
<route>
    <from uri="direct:index" />
    <to uri="elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet"/>
</route>

客户端只需要将含有 map 的正文消息传递给路由。结果正文包含创建的 indexId。

Map<String, String> map = new HashMap<String, String>();
map.put("content", "test");
String indexId = template.requestBody("direct:index", map, String.class);