95.6. インデックスの例

以下は単純な INDEX の例です

from("direct:index")
  .to("elasticsearch-rest://elasticsearch?operation=Index&indexName=twitter&indexType=tweet");
<route>
    <from uri="direct:index" />
    <to uri="elasticsearch-rest://elasticsearch?operation=Index&indexName=twitter&indexType=tweet"/>
</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);