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:

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)

name

description

operation

required, indicates the operation to perform

indexName

the name of the index to act against

indexType

the type of the index to act against

ip

the TransportClient remote host ip to use Camel 2.12

port

the TransportClient remote port to use (defaults to 9300) Camel 2.12

transportAddresses

comma separated list with ip:port formatted remote transport addresses to use Camel 2.16

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

consistencyLevel

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

replicationType

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

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

parent

optionally used with INDEX operations for Elasticsearch Parent-Child relationships to specify the ID of the parent record Camel 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 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.

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

List or Collection of any type that is already accepted (XContentBuilder, Map, byte[], 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

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

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

SEARCH

Map or SearchRequest Object

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

MULTIGET

List of MultigetRequest.Item object

Camel 2.17: retrieves the specified indexes, types etc. in MultigetRequest and returns a MultigetResponse object in the body

MULTISEARCH

List of SearchRequest object

Camel 2.17: search for parameters specified in MultiSearchRequest and returns a MultiSearchResponse object in the body

EXISTS

Index name as header

Camel 2.17: Returns a Boolean object in the body
UPDATEMap, String, byte[] or XContentBuilder content to updateCamel 2.17: Updates content to an index and returns the content's indexId in the body.

Index Example

Below is a simple INDEX example

A client would simply need to pass a body message containing a Map to the route. The result body contains the indexId created.

For more information, see these resources

ElasticSearch Main Site

ElasticSearch Java API

See Also

  • No labels

0 Comments