<html>
<head>
<base href="https://cwiki.apache.org/confluence">
<link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CAMEL&forWysiwyg=true"
type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/ElasticSearch">ElasticSearch</a></h2>
<h4>Page <b>edited</b> by <a href="https://cwiki.apache.org/confluence/display/~boday">Ben
O'Day</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
updated per CAMEL-6444<br />
</div>
<br/>
<h4>Changes (1)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >|indexName|the name of the index to
act against <br>|indexType|the type of the index to act against <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">|ip|the
TransportClient remote host ip to use *Camel 2.12* <br>|port|the TransportClient remote
port to use (defaults to 9300) *Camel 2.12* <br></td></tr>
<tr><td class="diff-unchanged" > <br>h3. Message Operations
<br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h2><a name="ElasticSearch-ElasticSearchComponent"></a>ElasticSearch
Component</h2>
<p><b>Available as of Camel 2.11</b></p>
<p>The ElasticSearch component allows you to interface with an <a href="http://elasticsearch.org"
class="external-link" rel="nofollow">ElasticSearch</a> server.</p>
<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
<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>
</pre>
</div></div>
<h3><a name="ElasticSearch-URIformat"></a>URI format</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
elasticsearch://[clusterName]?[options]
</pre>
</div></div>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>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 <a href="http://www.elasticsearch.org/guide/reference/java-api/client.html" class="external-link"
rel="nofollow">client guide</a> for more details.</td></tr></table></div>
<h3><a name="ElasticSearch-EndpointOptions"></a>Endpoint Options</h3>
<p>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)</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>name </th>
<th class='confluenceTh'>description</th>
</tr>
<tr>
<td class='confluenceTd'>operation</td>
<td class='confluenceTd'>required, indicates the operation to perform</td>
</tr>
<tr>
<td class='confluenceTd'>indexName</td>
<td class='confluenceTd'>the name of the index to act against</td>
</tr>
<tr>
<td class='confluenceTd'>indexType</td>
<td class='confluenceTd'>the type of the index to act against</td>
</tr>
<tr>
<td class='confluenceTd'>ip</td>
<td class='confluenceTd'>the TransportClient remote host ip to use <b>Camel 2.12</b></td>
</tr>
<tr>
<td class='confluenceTd'>port</td>
<td class='confluenceTd'>the TransportClient remote port to use (defaults to 9300) <b>Camel
2.12</b></td>
</tr>
</tbody></table>
</div>
<h3><a name="ElasticSearch-MessageOperations"></a>Message Operations</h3>
<p>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.</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>operation </th>
<th class='confluenceTh'>message body </th>
<th class='confluenceTh'>description</th>
</tr>
<tr>
<td class='confluenceTd'>INDEX</td>
<td class='confluenceTd'>Map, String, byte[] or XContentBuilder content to index</td>
<td class='confluenceTd'>adds content to an index and returns the content's indexId
in the body</td>
</tr>
<tr>
<td class='confluenceTd'>GET_BY_ID</td>
<td class='confluenceTd'>index id of content to retrieve</td>
<td class='confluenceTd'>retrives the specified index and returns a GetResult object
in the body</td>
</tr>
<tr>
<td class='confluenceTd'>DELETE</td>
<td class='confluenceTd'>index id of content to delete</td>
<td class='confluenceTd'>deletes the specified indexId and returns a DeleteResult object
in the body</td>
</tr>
</tbody></table>
</div>
<h3><a name="ElasticSearch-IndexExample"></a>Index Example</h3>
<p>Below is a simple INDEX example</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("direct:index")
.to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
</pre>
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
<route>
<from uri="direct:index" />
<to uri="elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet"/>
</route>
</pre>
</div></div>
<p>A client would simply need to pass a body message containing a Map to the route.
The result body contains the indexId created.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
Map<String, String> map = new HashMap<String, String>();
map.put("content", "test");
String indexId = template.requestBody("direct:index", map, String.class);
</pre>
</div></div>
<h3><a name="ElasticSearch-Formoreinformation%2Cseetheseresources"></a>For
more information, see these resources</h3>
<p><a href="http://elasticsearch.org" class="external-link" rel="nofollow">ElasticSearch
Main Site</a></p>
<p><a href="http://www.elasticsearch.org/guide/reference/java-api/" class="external-link"
rel="nofollow">ElasticSearch Java API</a></p>
<h3><a name="ElasticSearch-SeeAlso"></a>See Also</h3>
<ul>
<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop
watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
<a href="https://cwiki.apache.org/confluence/display/CAMEL/ElasticSearch">View
Online</a>
|
<a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30146765&revisedVersion=4&originalVersion=3">View
Changes</a>
|
<a href="https://cwiki.apache.org/confluence/display/CAMEL/ElasticSearch?showComments=true&showCommentArea=true#addcomment">Add
Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
|