このコンテンツは選択した言語では利用できません。

Chapter 90. Elasticsearch5 Component (deprecated)


Available as of Camel version 2.19

The ElasticSearch component allows you to interface with an ElasticSearch 5.x API.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-elasticsearch5</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap

90.1. URI format

elasticsearch5://clusterName[?options]
Copy to Clipboard Toggle word wrap

90.2. Endpoint Options

The Elasticsearch5 component supports 2 options which are listed below.

Expand
NameDescriptionDefaultType

client (advanced)

To use an existing configured Elasticsearch client, instead of creating a client per endpoint. This allow to customize the client with specific settings.

 

TransportClient

resolveProperty Placeholders (advanced)

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

boolean

The Elasticsearch5 endpoint is configured using URI syntax:

elasticsearch5:clusterName
Copy to Clipboard Toggle word wrap

with the following path and query parameters:

90.2.1. Path Parameters (1 parameters):

Expand
NameDescriptionDefaultType

clusterName

Required Name of the cluster

 

String

90.2.2. Query Parameters (16 parameters):

Expand
NameDescriptionDefaultType

clientTransportSniff (producer)

Is the client allowed to sniff the rest of the cluster or not. This setting map to the client.transport.sniff setting.

false

boolean

indexName (producer)

The name of the index to act against

 

String

indexType (producer)

The type of the index to act against

 

String

ip (producer)

The TransportClient remote host ip to use

 

String

operation (producer)

What operation to perform

 

ElasticsearchOperation

pingSchedule (producer)

The time(in unit) the client ping the cluster.

5s

String

pingTimeout (producer)

The time(in unit) to wait for a ping response from a node too return.

5s

String

port (producer)

The TransportClient remote port to use (defaults to 9300)

9300

int

tcpCompress (producer)

true if compression (LZF) enable between all nodes.

false

boolean

tcpConnectTimeout (producer)

The time( in unit) to wait for connection timeout.

30s

String

transportAddresses (producer)

Comma separated list with ip:port formatted remote transport addresses to use. The ip and port options must be left blank for transportAddresses to be considered instead.

 

String

waitForActiveShards (producer)

Index creation waits for the write consistency number of shards to be available

1

int

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

enableSSL (security)

Enable SSL. Require XPack client jar on the classpath

false

boolean

password (authentication)

Password for authenticate against the cluster. Require XPack client jar on the classpath

 

String

user (authentication)

User for authenticate against the cluster. Requires transport_client role for accessing the cluster. Require XPack client jar on the classpath

 

String

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

Expand
operationmessage bodydescription

INDEX

Map, String, byte[] or XContentBuilder content to index

Adds content to an index and returns the content’s indexId in the body. 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 name and type of content to delete

Deletes the specified indexName and indexType and returns a DeleteResponse object in the body

DELETE_INDEX

index name of content to delete

Deletes the specified indexName and returns a DeleteIndexResponse object in the body

BULK_INDEX

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

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)

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

SEARCH

Map, String or SearchRequest Object

Search the content with the map of query string

MULTIGET

List of MultigetRequest.Item object

Retrieves the specified indexes, types etc. in MultigetRequest and returns a MultigetResponse object in the body

MULTISEARCH

List of SearchRequest object

Search for parameters specified in MultiSearchRequest and returns a MultiSearchResponse object in the body

EXISTS

Index name as header

Checks the index exists or not and returns a Boolean flag in the body

UPDATE

Map, String, byte[] or XContentBuilder content to update

Updates content to an index and returns the content’s indexId in the body.

90.4. Index Example

Below is a simple INDEX example

from("direct:index")
.to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet");
Copy to Clipboard Toggle word wrap
<route>
    <from uri="direct:index" />
    <to uri="elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet"/>
</route>
Copy to Clipboard Toggle word wrap

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

Map<String, String> map = new HashMap<String, String>();
map.put("content", "test");
String indexId = template.requestBody("direct:index", map, String.class);
Copy to Clipboard Toggle word wrap

90.5. For more information, see these resources

Elastic Main Site

ElasticSearch Java API

90.6. See Also

  • Configuring Camel
  • Component
  • Endpoint
  • Getting Started
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat