...
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> |
...
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. | 12transportAddresses | comma 16. Options | ||||||
| From Camel 2.16. | ||||||||
| From Camel 2.16. | replicationType | the The replication type to use with with
| ||||||
| From Camel 2.16.1 / 2.17.0 Optionally used with optionally used with | ||||||||
| 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 value is : |
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 content to an index and return a List of the id of the successfully indexed documents in the body. |
| a A | From Camel 2.15: Adds content to an index and returns the the |
|
| From Camel 2.15: search the content with the map of query string. |
|
| From Camel 2.17: retrieves the specified indexes, types etc. inin a |
|
| From Camel 2.17:search for parameters specified inin a |
| Index name as a header. | From Camel 2.17: Returns a Boolean object in the body. |
|
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 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); |
...