Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 41. ElasticSearch
ElasticSearch Component 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Available as of Camel 2.11
The ElasticSearch component allows you to interface with an ElasticSearch server.
Maven users will need to add the following dependency to their
pom.xml
for this component:
URI format 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
elasticsearch://clusterName?[options]
elasticsearch://clusterName?[options]
Tip
If you want to run against a local (in JVM/classloader) ElasticSearch server, just set the clusterName value in the URI to
local
. See the client guide for more details.
Endpoint Options 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following options may be configured on the ElasticSearch endpoint. All are required to be set as either an endpoint URI parameter or as a header (headers override endpoint properties)
name | description |
---|---|
operation
|
required, indicates the operation to perform |
indexName
|
the name of the index to act against
|
ip
|
the TransportClient remote host ip to use Camel 2.12
|
Message Operations 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following ElasticSearch operations are currently supported. Simply set an endpoint URI option or exchange header with a key of
operation
and a value set to one of the following. Some operations also require other parameters or the message body to be set.
operation | message body | description |
---|---|---|
INDEX
|
Map , String , byte[] or XContentBuilder content to index
|
Adds content to an index and returns the content's indexId in the body.
|
GET_BY_ID
|
Index ID of content to retrieve |
Retrieves the specified index and returns a GetResult object in the body.
|
DELETE
|
Index ID of content to delete |
Deletes the specified indexId and returns a DeleteResult object in the body.
|
BULK_INDEX
|
A List or Collection of any type that is already accepted (
XContentBuilder , Map , byte[] , or String )
|
Camel 2.14, Adds content to an index and return a List of the id of the successfully indexed documents in the body.
|
BULK
|
A List or Collection of any type that is already accepted (
XContentBuilder , Map , byte[] , or String )
|
Camel 2.15, Adds content to an index and returns the BulkResponse object in the body.
|
Index Example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Below is a simple INDEX example
from("direct:index") .to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
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>
<route>
<from uri="direct:index" />
<to uri="elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet"/>
</route>
A client would simply need to pass a body message containing a Map to the route. The result body contains the indexId created.
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);
Java Example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following example shows how to use the ElasticSearch component from a Camel route defined in Java:
For more information, see these resources 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!