...
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 | ||||
---|---|---|---|---|
| ||||
<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] |
Tip | ||
---|---|---|
| ||
if you want to run against a local (in JVM/classloader) ElasticSearch server, just set the the |
...
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)
nameName | descriptionDescription | |||||
---|---|---|---|---|---|---|
| Required. The required, indicates the operation to perform. | |||||
| the The name of the index to act against. | |||||
| the The type of the index to act against. | |||||
| From Camel 2.12. | |||||
| From Camel 2.12. | port | the The | |||
| From Camel 2.16. | 12transportAddresses | comma Comma separated list with ip Options | |||
| From Camel 2.16. Can be one of:
| |||||
| From Camel 2.16. | replicationType | the The replication type to use with with Can be one of:
| |||
| optionally used with From Camel 2.16.1 / 2.17.0 Optionally used with | the the | ||||
| From Camel 2.17 Define if the client is allowed to sniff the rest of the cluster. | |||||
| From Camel 2.17.2 Define the Default: |
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 | |||
---|---|---|---|---|---|
|
| adds Adds content to an index and returns the content's s From Camel 2.15,: you can set the the | |||
| index Index id of content to retrieve. | retrieves Retrieves the specified index and returns a a | |||
| index Index id of content to delete. | deletes Deletes the specified specified | |||
| a A | From Camel 2.14, adds : Adds content to an index and return a List a | |||
| a A | From Camel 2.15: Adds content to an index and returns the the | |||
|
| From Camel 2.15: searchSearch the content with the map ofthe | |||
|
| of of | retrieves From Camel 2.17: | Retrieves the specified indexes | , types etc. in MultigetRequest and returns a MultigetResponse type's specified in |
|
| From Camel 2.17: Search for parameters specified in | |||
| Index name as a header. | From Camel 2.17: Returns a | |||
|
or content to update. | From Camel 2.17: Updates content to an index and returns the content' ss |
Index Example
Below is a simple simple INDEX
example:
Code Block | ||||
---|---|---|---|---|
| ||||
from("direct:index")
.to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
|
Code Block | ||||
---|---|---|---|---|
| ||||
<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 a Map
to the route. The result body contains the the indexId
created.:
Code Block | ||||
---|---|---|---|---|
| ||||
Map<String, String> map = new HashMap<String, String>(); map.put("content", "test"); String indexId = template.requestBody("direct:index", map, String.class); |
...