22.8. インデックスの例
以下は単純な INDEX の例です
from("direct:index") .to("elasticsearch://elasticsearch?operation=Index&indexName=twitter");
from("direct:index")
.to("elasticsearch://elasticsearch?operation=Index&indexName=twitter");
<route> <from uri="direct:index"/> <to uri="elasticsearch://elasticsearch?operation=Index&indexName=twitter"/> </route>
<route>
<from uri="direct:index"/>
<to uri="elasticsearch://elasticsearch?operation=Index&indexName=twitter"/>
</route>
この操作では、indexId ヘッダーを指定する必要があります。
クライアントは、Map を含む本文メッセージをルートに渡すだけで済みます。結果の本文には、作成された indexId が含まれます。
Map<String, String> map = new HashMap<String, String>(); map.put("content", "test"); String indexId = template.requestBody("direct:index", map, String.class);
Map<String, String> map = new HashMap<String, String>();
map.put("content", "test");
String indexId = template.requestBody("direct:index", map, String.class);