This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • ElasticSearch
Skip to end of metadata
Go to start of metadata

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:

    <!-- use the same version as your Camel core version -->

URI Format


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)





The operation to perform.


The name of the index.


The type of the index.


From Camel 2.12.
The TransportClient remote host IP address to use.


From Camel 2.12.
The TransportClient remote port to use (defaults to 9300).


From Camel 2.16.
Comma separated list with IP:PORT formatted remote transport addresses to use.

Options IP and PORT must be left blank for transportAddresses to be considered instead.


From Camel 2.16.
The write consistency level to use with INDEX and BULK operations.

Can be one of:

  • ONE
  • ALL


From Camel 2.16.
The replication type to use with INDEX and BULK operations.

Can be one of:

  • SYNC

From Camel 2.17 the option replicationType has been removed, as the async replication was removed in Elasticsearch 2.0.0.


From Camel 2.16.1 / 2.17.0

Optionally used with INDEX operations for Elasticsearch Parent-Child relationships to specify the ID of the parent record.


From Camel 2.17

Define if the client is allowed to sniff the rest of the cluster.


From Camel 2.17.2 

Define the path.home property inside settings of ElasticSearch node.  

Default: /usr/share/elasticsearch

Message Operations

The following ElasticSearch operations are currently supported. Simply set an endpoint URI option or an exchange header with name operation and a value set to one of the following. Some operations also require other parameters or the message body to be set.


Message body



Map, Stringbyte[] or XContentBuilder content to index.

Adds content to an index and returns the content's indexId in the body.

From Camel 2.15: you can set the indexId by setting the message header with the key "indexId".


Index id of content to retrieve.

Retrieves the specified index and returns a GetResult object in the body.


Index id of content to delete.

Deletes the specified indexId and returns a DeleteResult object in the body.


A List or Collection of any type that is already accepted (Map, Stringbyte[] or XContentBuilder).

From Camel 2.14: Adds content to an index and return a List of the id's of the successfully indexed documents in the body.


List or Collection of any type that is already accepted (Map, Stringbyte[] or XContentBuilder).

From Camel 2.15: Adds content to an index and returns the BulkResponse object in the body.


Map or SearchRequest object.

From Camel 2.15: Search the content with the Map or query string.


List of MultigetRequest.Item object.

From Camel 2.17: Retrieves the specified indexes type's specified in MultigetRequest and returns a MultigetResponse object in the body.


List of SearchRequest object.

From Camel 2.17: Search for parameters specified in MultiSearchRequest and returns a MultiSearchResponse object in the body.


Index name as a header.

From Camel 2.17: Returns a Boolean object in the body.


Map, Stringbyte[] or XContentBuilder content to update.

From Camel 2.17: Updates content to an index and returns the content's indexId in the body.

Index Example

Below is a simple INDEX example:

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

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);

For more information, see these resources

ElasticSearch Main Site

ElasticSearch Java API

  • No labels