Versions Compared

Key

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

...

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:

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>

URI

...

Format

Code Block
elasticsearch://clusterName[?options]

...

Name

Description

operation

Required.

The operation to perform.

indexName

The name of the index.

indexType

The type of the index.

ip

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

port

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

transportAddresses

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.

consistencyLevel

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

Can be one of:

  • ONE
  • QUORUM
  • ALL
  • DEFAULT

replicationType

From Camel 2.16.
The replication type to use with INDEX and BULK operations (can be any of SYNCASYNC or DEFAULT). .

Can be one of:

  • SYNC
  • ASYNC
  • DEFAULT
Warning
From Camel 2.17 the option replicationType has been removed, as from Elasticsearch 2.0.0 the async replication has been removed.

parent

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.

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 the path.home property inside settings of ElasticSearch node.  

Default: /usr/share/elasticsearch

...

Operation

Message body

Description

INDEX

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".

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 (Map, Stringbyte[] or XContentBuilder).

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

BULK

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.

SEARCH

Map or SearchRequest object.

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

MULTIGET

List of MultigetRequest.Item object.

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

MULTISEARCH

List of SearchRequest object.

From Camel 2.17: search Search for parameters specified 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, Stringbyte[] or XContentBuilder content to update.

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

...

Below is a simple INDEX example:

Code Block
java
java
from("direct:index")
  .to("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.:

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

...