94.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 헤더를 지정해야 합니다.

클라이언트는 맵을 포함하는 본문 메시지를 경로로 전달하기만 하면 됩니다. 결과 본문에는 생성된 indexId가 포함되어 있습니다.

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