Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-elasticsearch</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

...

Tip
clusterNamelocal

if you want to run against a local (in JVM/classloader) ElasticSearch server, just set the the clusterName value in the URI to "local". See the client guide for more details.

...

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)

12

nameName

descriptionDescription

operation

Required.

The required, indicates the operation to perform.

indexName

the The name of the index to act against.

indexType

the The type of the index to act against.

ip

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

port

From Camel 2.12.

port

the The TransportClient remote port to use (defaults to to 9300).

transportAddresses

From Camel 2.

transportAddresses

comma 16.
Comma separated list with ipIP:portPORT formatted remote transport addresses to useCamel 2.16

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

consistencyLevel

From Camel 2.16.
The the write consistency level to use with with INDEX and and BULK operations (can be any of of ONE, QUORUM, ALL or DEFAULT).

replicationType

From Camel 2.16.

replicationType

the The replication type to use with with INDEX and and BULK operations (can be any of SYNC, ASYNC or DEFAULT)Camel 2. 16

Warning
From
version
Camel 2.17 the option replicationType
option
has been removed,
since
as from
elasticsearch
Elasticsearch 2.0.0 the async replication has been removed.

parent

From Camel 2.16.1 / 2.17.0

Optionally used with optionally used with INDEX operations for Elasticsearch Parent-Child relationships to specify the the ID of the parent recordCamel 2.16.1 / 2.17.0

clientTransportSniff

From Camel 2.17

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

pathHome

From Camel 2.17.2 

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

Default value is : /usr/share/elasticsearch

Message Operations

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

operationOperation

message Message body

descriptionDescription

INDEX

Map, String, byte[] or or XContentBuilder content to index.

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

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

GET_BY_ID

index Index id of content to retrieve.

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

DELETE

index Index id of content to delete.

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

BULK_INDEX

A List or or Collection of any type that is already accepted (XContentBuilderMap, Map String, byte[], String or XContentBuilder)

From Camel 2.14, adds content to an index and return a List of the id of the successfully indexed documents in the body.

BULK

List or or Collection of any type that is already accepted (XContentBuilderMap, Map String, byte[], String or XContentBuilder)

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

SEARCH

Map or  or SearchRequest Object object.

From Camel 2.15: search the content with the map of query string.

MULTIGET

List of  of MultigetRequest.Item object.

From Camel 2.17: retrieves the specified indexes, types etc.

in

in MultigetRequest and returns

a

MultigetResponse object in the body.

MULTISEARCH

List of  of SearchRequest object.

From Camel 2.17:search for parameters specified

in

in MultiSearchRequest and returns

a

MultiSearchResponse object in the body.

EXISTS

Index name as a header.

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

UPDATE

Map, String, byte[]

or

or XContentBuilder

content

 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 simple INDEX example

Code Block
java
java
from("direct:index")
  .to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
Code Block
xml
xml
<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 the indexId created.

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

...