이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 90. Elasticsearch Component (deprecated)


Available as of Camel version 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:

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

90.1. URI format

elasticsearch://clusterName[?options]

90.2. Endpoint Options

The Elasticsearch component supports 2 options which are listed below.

NameDescriptionDefaultType

client (advanced)

To use an existing configured Elasticsearch client, instead of creating a client per endpoint.

 

Client

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 Elasticsearch endpoint is configured using URI syntax:

elasticsearch:clusterName

with the following path and query parameters:

90.2.1. Path Parameters (1 parameters):

NameDescriptionDefaultType

clusterName

Required Name of cluster or use local for local mode

 

String

90.2.2. Query Parameters (11 parameters):

NameDescriptionDefaultType

clientTransportSniff (producer)

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

true

Boolean

consistencyLevel (producer)

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

DEFAULT

WriteConsistencyLevel

data (producer)

Is the node going to be allowed to allocate data (shards) to it or not. This setting map to the node.data setting.

 

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

 

String

pathHome (producer)

The path.home property of ElasticSearch configuration. You need to provide a valid path, otherwise the default, $user.home/.elasticsearch, will be used.

${user.home}/.elasticsearch

String

port (producer)

The TransportClient remote port to use (defaults to 9300)

9300

int

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

synchronous (advanced)

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

false

boolean

90.3. Local testing

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.

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

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

UPDATE

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

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

90.5. Index Example

Below is a simple INDEX example

from("direct:index")
.to("elasticsearch://local?operation=INDEX&indexName=twitter&indexType=tweet");
<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 indexId created.

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

90.6. For more information, see these resources

ElasticSearch Main Site

ElasticSearch Java API

90.7. See Also

  • Configuring Camel
  • Component
  • Endpoint
  • Getting Started
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.