This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 6231fdf27 Fix #3376: new elasticsearch-search-action and
opensearch-search-action Kamelets (#3380)
6231fdf27 is described below
commit 6231fdf2708afa183e4dfb782c91c45a017c2ac4
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 23 17:39:30 2026 +0100
Fix #3376: new elasticsearch-search-action and opensearch-search-action
Kamelets (#3380)
* Fix #3376: new elasticsearch-search-action and opensearch-search-action
Kamelets, search an index as a step of a route
Both Kamelets are Preview. The body is the search: text that starts with
`{` (or a Map) is the Query DSL, a query alone or a `_search` request body;
any other text is searched for as words in all the fields, through a fixed
`multi_match` query in the template, into which the text is put with
`${escape(json)}`, so it cannot add to the request.
The output is a fixed JSON array, as text, of the `_source` of the hits
(the documents are read as Maps and marshalled with Jackson), with the
number of matches in the `CamelElasticsearchTotalHits` /
`CamelOpensearchTotalHits` header. The old search sources were removed
because Gson marshalled the client objects as `{"_children": ...}`; no
client object leaves these Kamelets.
The index and the size come from the options. The `CamelElasticsearch*` /
`CamelOpensearch*` headers are removed before the search, so a message
cannot change the index, the operation, the size, the document class or
turn on scrolling. The `size` option takes precedence over a `size` in the
search.
The Citrus tests (SearchIT) index two customers and one document in
another index, then search with a Query DSL query while a header asks for
the other index, with plain text, and with a query that finds nothing,
and check the body, its type, the total and the Content-Type.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: regenerate the catalog files after merging main
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel-kamelets-catalog-sbom.json | 18 ++-
docs/modules/ROOT/nav.adoc | 2 +
kamelets/elasticsearch-search-action.kamelet.yaml | 162 +++++++++++++++++++
kamelets/opensearch-search-action.kamelet.yaml | 167 +++++++++++++++++++
.../main/resources/META-INF/kamelets-index.json | 20 +++
.../elasticsearch-search-action.kamelet.yaml | 162 +++++++++++++++++++
.../kamelets/opensearch-search-action.kamelet.yaml | 167 +++++++++++++++++++
...lasticsearch-search-action-route.citrus.it.yaml | 176 ++++++++++++++++++++
.../elasticsearch-search-action-route.yaml | 94 +++++++++++
.../opensearch-search-action-route.citrus.it.yaml | 178 +++++++++++++++++++++
.../opensearch/opensearch-search-action-route.yaml | 94 +++++++++++
11 files changed, 1239 insertions(+), 1 deletion(-)
diff --git a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
index 2231f05bd..b54713f07 100644
--- a/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
+++ b/camel-kamelets-sbom/camel-kamelets-catalog-sbom.json
@@ -396,6 +396,11 @@
"type" : "library",
"name" : "elasticsearch-index-sink",
"version" : "4.24.0-SNAPSHOT"
+ }, {
+ "bom-ref" : "kamelet:elasticsearch-search-action",
+ "type" : "library",
+ "name" : "elasticsearch-search-action",
+ "version" : "4.24.0-SNAPSHOT"
}, {
"bom-ref" : "kamelet:exec-sink",
"type" : "library",
@@ -861,6 +866,11 @@
"type" : "library",
"name" : "opensearch-index-sink",
"version" : "4.24.0-SNAPSHOT"
+ }, {
+ "bom-ref" : "kamelet:opensearch-search-action",
+ "type" : "library",
+ "name" : "opensearch-search-action",
+ "version" : "4.24.0-SNAPSHOT"
}, {
"bom-ref" : "kamelet:oracle-database-sink",
"type" : "library",
@@ -2537,7 +2547,7 @@
} ],
"dependencies" : [ {
"ref" : "camel-kamelets-catalog",
- "dependsOn" : [ "kamelet:ai-tool-source",
"kamelet:avro-deserialize-action", "kamelet:avro-serialize-action",
"kamelet:aws-bedrock-agent-runtime-sink", "kamelet:aws-bedrock-agent-sink",
"kamelet:aws-bedrock-text-sink", "kamelet:aws-cloudtrail-source",
"kamelet:aws-cloudwatch-sink", "kamelet:aws-comprehend-sink",
"kamelet:aws-ddb-sink", "kamelet:aws-ddb-streams-source",
"kamelet:aws-ec2-sink", "kamelet:aws-eventbridge-sink",
"kamelet:aws-eventbridge-source", "kamelet:aws-kinesis-fireh [...]
+ "dependsOn" : [ "kamelet:ai-tool-source",
"kamelet:avro-deserialize-action", "kamelet:avro-serialize-action",
"kamelet:aws-bedrock-agent-runtime-sink", "kamelet:aws-bedrock-agent-sink",
"kamelet:aws-bedrock-text-sink", "kamelet:aws-cloudtrail-source",
"kamelet:aws-cloudwatch-sink", "kamelet:aws-comprehend-sink",
"kamelet:aws-ddb-sink", "kamelet:aws-ddb-streams-source",
"kamelet:aws-ec2-sink", "kamelet:aws-eventbridge-sink",
"kamelet:aws-eventbridge-source", "kamelet:aws-kinesis-fireh [...]
}, {
"ref" : "kamelet:ai-tool-source",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -2769,6 +2779,9 @@
}, {
"ref" : "kamelet:elasticsearch-index-sink",
"dependsOn" : [ "pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ }, {
+ "ref" : "kamelet:elasticsearch-search-action",
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:exec-sink",
"dependsOn" : [ "pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
@@ -3048,6 +3061,9 @@
}, {
"ref" : "kamelet:opensearch-index-sink",
"dependsOn" : [ "pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
+ }, {
+ "ref" : "kamelet:opensearch-search-action",
+ "dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]" ]
}, {
"ref" : "kamelet:oracle-database-sink",
"dependsOn" : [
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.camel/[email protected]",
"pkg:maven/org.apache.commons/[email protected]" ]
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 339d553d4..99263a12c 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -76,6 +76,7 @@
* xref:drop-header-action.adoc[]
* xref:drop-headers-action.adoc[]
* xref:elasticsearch-index-sink.adoc[]
+* xref:elasticsearch-search-action.adoc[]
* xref:exec-sink.adoc[]
* xref:extract-field-action.adoc[]
* xref:fhir-sink.adoc[]
@@ -169,6 +170,7 @@
* xref:ogcapi-features-action.adoc[]
* xref:openai-chat-action.adoc[]
* xref:opensearch-index-sink.adoc[]
+* xref:opensearch-search-action.adoc[]
* xref:oracle-database-sink.adoc[]
* xref:oracle-database-source.adoc[]
* xref:pdf-action.adoc[]
diff --git a/kamelets/elasticsearch-search-action.kamelet.yaml
b/kamelets/elasticsearch-search-action.kamelet.yaml
new file mode 100644
index 000000000..ca95ab377
--- /dev/null
+++ b/kamelets/elasticsearch-search-action.kamelet.yaml
@@ -0,0 +1,162 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: elasticsearch-search-action
+ labels:
+ camel.apache.org/kamelet.type: "action"
+ camel.apache.org/kamelet.verified: "true"
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1NTAgMjUwIiB2aWV3Qm94PSI3Nyw4Myw0MTAsOTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiA8cGF0aCBkPSJtMTc4IDEwMi41aDMxM3Y0MWgtMzEzeiIgZmlsbD0ibm9uZSIvPgogPGcgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyI+CiAgPHBhdGggZD0ibTE5My4zIDEzOS40Yy00IDAtNy4yLTEuMi05LjUtMy41cy0zLjQtNS42LTMuNC05LjdjMC00LjIgMS4xLTcuNiAzLjItMTBzNS0zLjYgOC43LTMuNmMzLjQgMCA2Lj
[...]
+ camel.apache.org/kamelet.group: "ElasticSearch"
+ camel.apache.org/kamelet.namespace: "Search"
+ camel.apache.org/provider: "Apache Software Foundation"
+spec:
+ definition:
+ title: "ElasticSearch Search Action"
+ description: |-
+ Searches an index of Elasticsearch for each message, and gives back the
documents found, as a JSON array.
+
+ Use it to look something up in the middle of a flow, for example to find
the customer of an order, or to enrich an event with the records that match it.
To store documents in Elasticsearch, use `elasticsearch-index-sink`; for
OpenSearch, use `opensearch-search-action`.
+
+ Input: the body is the search. Text that starts with `{` is a search in
the Query DSL of Elasticsearch, as JSON text: either a query alone, such as
`{"match": {"city": "Oslo"}}`, or the body of a `_search` request with a
`query`, such as `{"query": {"match_all": {}}, "sort": [{"age": "desc"}]}`. Any
other text is searched for as words in all the fields of the documents: `Oslo
Rome` finds the documents that contain Oslo or Rome. An empty body finds
nothing. Bytes are read as text, a [...]
+
+ Output: the body is a JSON array, as text, with the documents found
(their `_source`), best match first unless the search has a `sort`, such as
`[{"name": "Alice Smith", "city": "Oslo"}]`; an empty array `[]` when nothing
matches. The `CamelElasticsearchTotalHits` header is the number of documents
that match, which can be more than the documents in the body. The
`Content-Type` header is `application/json`.
+
+ Good to know: the body holds at most `size` documents; a `size` in the
search is ignored. Elasticsearch stops counting the matches at 10000, so a
larger number is given as 10000. A search with `"_source": false` gives an
empty array. A search that is not valid JSON, an index that does not exist, or
a query that Elasticsearch rejects, fails the message. Headers that start with
`CamelElasticsearch` are removed from the message first, so they cannot change
the index, the operation or [...]
+ required:
+ - clusterName
+ - hostAddresses
+ - indexName
+ type: object
+ properties:
+ user:
+ title: Username
+ description: The Elasticsearch user to log in as, such as `elastic`.
Leave it out for a cluster without security.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password of the Elasticsearch user in `user`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ enableSSL:
+ title: Enable SSL
+ description: If true, it connects with HTTPS. Set it to false for a
cluster that is reached with plain HTTP.
+ type: boolean
+ default: true
+ hostAddresses:
+ title: Host Addresses
+ description: The address of the Elasticsearch HTTP API, as
`host:port`, or several nodes separated by commas. The port is 9200 by default.
+ type: string
+ example: quickstart-es-http:9200
+ clusterName:
+ title: ElasticSearch Cluster Name
+ description: The name of the Elasticsearch cluster. Required, but not
checked against the cluster.
+ type: string
+ example: quickstart
+ indexName:
+ title: Index in ElasticSearch
+ description: The name of the index to search.
+ type: string
+ example: customers
+ size:
+ title: Size
+ description: The largest number of documents to give back in the body,
for each message. It takes precedence over a `size` in the search.
+ type: integer
+ default: 10
+ certificate:
+ title: Certificate
+ description: The certificate of the certificate authority (CA) that
signed the certificate of the cluster, such as the `http_ca.crt` file that
Elasticsearch generates, as a PEM or DER file encoded in base64 on one line,
such as the output of `base64 -w0 http_ca.crt` (`base64 -i http_ca.crt` on
macOS). Needed when the cluster uses a self-signed certificate, or one signed
by a private CA. When it is set, only this CA is trusted; when it is not set,
the certificates that Java trusts [...]
+ type: string
+ connectionTimeout:
+ title: Connection Timeout
+ description: How long to wait for the connection to Elasticsearch, in
milliseconds. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 5000
+ socketTimeout:
+ title: Socket Timeout
+ description: How long to wait for data from Elasticsearch, in
milliseconds. When Elasticsearch sends nothing for this long, the message
fails. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 10000
+ dataTypes:
+ # No 'default:' on purpose: the body is made text in the template. See
#3117.
+ in:
+ headers: {}
+ out:
+ headers:
+ CamelElasticsearchTotalHits:
+ title: Total Hits
+ description: 'The number of documents that match the search, counted
up to 10000. It has no value when the search sets `"track_total_hits": false`.'
+ type: integer
+ dependencies:
+ - "camel:jackson3"
+ - "camel:kamelet"
+ - "camel:elasticsearch"
+ template:
+ beans:
+ - name: local-es
+ type: "#class:org.apache.camel.component.es.ElasticsearchComponent"
+ properties:
+ user: "{{?user}}"
+ password: "{{?password}}"
+ from:
+ uri: kamelet:source
+ steps:
+ - removeHeaders:
+ pattern: "CamelElasticsearch*"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body} !is 'java.util.Map'"
+ steps:
+ - convertBodyTo:
+ type: java.lang.String
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body.trim()} !startsWith '{'"
+ steps:
+ - setBody:
+ expression:
+ simple:
+ expression: '{"query": {"multi_match":
{"query": "${escape(json)}"} } }'
+ - to:
+ uri:
"{{local-es}}:{{clusterName}}?operation=Search&indexName={{indexName}}&size={{size}}&documentClass=java.util.Map&hostAddresses={{hostAddresses}}&enableSSL={{enableSSL}}&certificatePath=RAW(base64:{{?certificate}})&connectionTimeout={{?connectionTimeout}}&socketTimeout={{?socketTimeout}}"
+ - removeHeaders:
+ pattern: "CamelElasticsearch*"
+ - setHeader:
+ name: CamelElasticsearchTotalHits
+ expression:
+ simple:
+ expression: "${body?.total.value}"
+ - setBody:
+ expression:
+ simple:
+ expression: "${forEach(${body.hits},${body.source})}"
+ - marshal:
+ json: {}
+ - convertBodyTo:
+ type: java.lang.String
diff --git a/kamelets/opensearch-search-action.kamelet.yaml
b/kamelets/opensearch-search-action.kamelet.yaml
new file mode 100644
index 000000000..37b4eae15
--- /dev/null
+++ b/kamelets/opensearch-search-action.kamelet.yaml
@@ -0,0 +1,167 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: opensearch-search-action
+ labels:
+ camel.apache.org/kamelet.type: "action"
+ camel.apache.org/kamelet.verified: "true"
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzNzIgNzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cjx0aXRsZT5PcGVuU2VhcmNoIGxvZ288L3RpdGxlPgo8ZGVzYz5TZWFyY2ggZW5naW5lIHNvZnR3YXJlIGZvcmsgb2YgRWxhc3RpY3NlYXJjaDwvZGVzYz4KIDxwYXRoIGQ9Im02MS43Mzc0IDI2LjVjLTEuMjQ5NiAwLTIuMjYyNiAxLjAxMy0yLjI2MjYgMi4yNjI2IDAgMTguNjE4OC0xNS4wOTM0IDMzLjcxMjItMzMuNzEyMiAzMy43MTIyLTEuMjQ5NiAwLTIuMjYyNi
[...]
+ camel.apache.org/kamelet.group: "OpenSearch"
+ camel.apache.org/kamelet.namespace: "Search"
+ camel.apache.org/provider: "Apache Software Foundation"
+spec:
+ definition:
+ title: "OpenSearch Search Action"
+ description: |-
+ Searches an index of OpenSearch for each message, and gives back the
documents found, as a JSON array.
+
+ Use it to look something up in the middle of a flow, for example to find
the customer of an order, or to enrich an event with the records that match it.
To store documents in OpenSearch, use `opensearch-index-sink`; for
Elasticsearch, use `elasticsearch-search-action`.
+
+ Input: the body is the search. Text that starts with `{` is a search in
the Query DSL of OpenSearch, as JSON text: either a query alone, such as
`{"match": {"city": "Oslo"}}`, or the body of a `_search` request with a
`query`, such as `{"query": {"match_all": {}}, "sort": [{"age": "desc"}]}`. Any
other text is searched for as words in all the fields of the documents: `Oslo
Rome` finds the documents that contain Oslo or Rome. An empty body finds
nothing. Bytes are read as text, and [...]
+
+ Output: the body is a JSON array, as text, with the documents found
(their `_source`), best match first unless the search has a `sort`, such as
`[{"name": "Alice Smith", "city": "Oslo"}]`; an empty array `[]` when nothing
matches. The `CamelOpensearchTotalHits` header is the number of documents that
match, which can be more than the documents in the body. The `Content-Type`
header is `application/json`.
+
+ Good to know: the body holds at most `size` documents; a `size` in the
search is ignored. OpenSearch stops counting the matches at 10000, so a larger
number is given as 10000. A search with `"_source": false` gives an empty
array. A search that is not valid JSON, an index that does not exist, or a
query that OpenSearch rejects, fails the message. Headers that start with
`CamelOpensearch` are removed from the message first, so they cannot change the
index, the operation or the size. [...]
+ required:
+ - clusterName
+ - hostAddresses
+ - indexName
+ type: object
+ properties:
+ user:
+ title: Username
+ description: The OpenSearch user to log in as, such as `admin`. Leave
it out for a cluster without security.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password of the OpenSearch user in `user`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ enableSSL:
+ title: Enable SSL
+ description: If true, it connects with HTTPS. Set it to false for a
cluster that is reached with plain HTTP.
+ type: boolean
+ default: true
+ hostAddresses:
+ title: Host Addresses
+ description: The address of the OpenSearch HTTP API, as `host:port`,
or several nodes separated by commas. The port is 9200 by default.
+ type: string
+ example: quickstart-es-http:9200
+ clusterName:
+ title: OpenSearch Cluster Name
+ description: The name of the OpenSearch cluster. Required, but not
checked against the cluster.
+ type: string
+ example: quickstart
+ indexName:
+ title: Index in OpenSearch
+ description: The name of the index to search.
+ type: string
+ example: customers
+ size:
+ title: Size
+ description: The largest number of documents to give back in the body,
for each message. It takes precedence over a `size` in the search.
+ type: integer
+ default: 10
+ sslContextParameters:
+ title: SSL Context Parameters
+ description: For TLS settings that `certificate` cannot give, such as
a client certificate (mutual TLS), a trust store, or a TLS version, an
`SSLContextParameters` object defined in the application, as `#bean:` followed
by its name. It takes precedence over `certificate`; set one or the other.
+ type: string
+ example: "#bean:mySslContext"
+ certificate:
+ title: Certificate
+ description: The certificate of the certificate authority (CA) that
signed the certificate of the cluster, such as the `root-ca.pem` file of the
OpenSearch demo configuration, as a PEM or DER file encoded in base64 on one
line, such as the output of `base64 -w0 root-ca.pem` (`base64 -i root-ca.pem`
on macOS). Needed when the cluster uses a self-signed certificate, or one
signed by a private CA. When it is set, only this CA is trusted; when it is not
set, the certificates that Jav [...]
+ type: string
+ connectionTimeout:
+ title: Connection Timeout
+ description: How long to wait for the connection to OpenSearch, in
milliseconds. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 5000
+ socketTimeout:
+ title: Socket Timeout
+ description: How long to wait for data from OpenSearch, in
milliseconds. When OpenSearch sends nothing for this long, the message fails.
When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 10000
+ dataTypes:
+ # No 'default:' on purpose: the body is made text in the template. See
#3117.
+ in:
+ headers: {}
+ out:
+ headers:
+ CamelOpensearchTotalHits:
+ title: Total Hits
+ description: 'The number of documents that match the search, counted
up to 10000. It has no value when the search sets `"track_total_hits": false`.'
+ type: integer
+ dependencies:
+ - "camel:jackson3"
+ - "camel:kamelet"
+ - "camel:opensearch"
+ template:
+ beans:
+ - name: local-opensearch
+ type:
"#class:org.apache.camel.component.opensearch.OpensearchComponent"
+ properties:
+ user: "{{?user}}"
+ password: "{{?password}}"
+ from:
+ uri: kamelet:source
+ steps:
+ - removeHeaders:
+ pattern: "CamelOpensearch*"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body} !is 'java.util.Map'"
+ steps:
+ - convertBodyTo:
+ type: java.lang.String
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body.trim()} !startsWith '{'"
+ steps:
+ - setBody:
+ expression:
+ simple:
+ expression: '{"query": {"multi_match":
{"query": "${escape(json)}"} } }'
+ - to:
+ uri:
"{{local-opensearch}}:{{clusterName}}?operation=Search&indexName={{indexName}}&size={{size}}&documentClass=java.util.Map&hostAddresses={{hostAddresses}}&enableSSL={{enableSSL}}&certificatePath=RAW(base64:{{?certificate}})&sslContextParameters={{?sslContextParameters}}&connectionTimeout={{?connectionTimeout}}&socketTimeout={{?socketTimeout}}"
+ - removeHeaders:
+ pattern: "CamelOpensearch*"
+ - setHeader:
+ name: CamelOpensearchTotalHits
+ expression:
+ simple:
+ expression: "${body?.total.value}"
+ - setBody:
+ expression:
+ simple:
+ expression: "${forEach(${body.hits},${body.source})}"
+ - marshal:
+ json: {}
+ - convertBodyTo:
+ type: java.lang.String
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index bb824ff6a..b11af2a79 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -769,6 +769,16 @@
"group" : "ElasticSearch",
"namespace" : "Search",
"provider" : "Apache Software Foundation"
+ }, {
+ "name" : "elasticsearch-search-action",
+ "type" : "action",
+ "supportLevel" : "Preview",
+ "title" : "ElasticSearch Search Action",
+ "summary" : "Searches an index of Elasticsearch for each message, and
gives back the documents found, as a JSON array.",
+ "description" : "Searches an index of Elasticsearch for each message, and
gives back the documents found, as a JSON array.\n\nUse it to look something up
in the middle of a flow, for example to find the customer of an order, or to
enrich an event with the records that match it. To store documents in
Elasticsearch, use `elasticsearch-index-sink`; for OpenSearch, use
`opensearch-search-action`.\n\nInput: the body is the search. Text that starts
with `{` is a search in the Query DSL of [...]
+ "group" : "ElasticSearch",
+ "namespace" : "Search",
+ "provider" : "Apache Software Foundation"
}, {
"name" : "exec-sink",
"type" : "sink",
@@ -1699,6 +1709,16 @@
"group" : "OpenSearch",
"namespace" : "Search",
"provider" : "Apache Software Foundation"
+ }, {
+ "name" : "opensearch-search-action",
+ "type" : "action",
+ "supportLevel" : "Preview",
+ "title" : "OpenSearch Search Action",
+ "summary" : "Searches an index of OpenSearch for each message, and gives
back the documents found, as a JSON array.",
+ "description" : "Searches an index of OpenSearch for each message, and
gives back the documents found, as a JSON array.\n\nUse it to look something up
in the middle of a flow, for example to find the customer of an order, or to
enrich an event with the records that match it. To store documents in
OpenSearch, use `opensearch-index-sink`; for Elasticsearch, use
`elasticsearch-search-action`.\n\nInput: the body is the search. Text that
starts with `{` is a search in the Query DSL of Ope [...]
+ "group" : "OpenSearch",
+ "namespace" : "Search",
+ "provider" : "Apache Software Foundation"
}, {
"name" : "oracle-database-sink",
"type" : "sink",
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/elasticsearch-search-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/elasticsearch-search-action.kamelet.yaml
new file mode 100644
index 000000000..ca95ab377
--- /dev/null
+++
b/library/camel-kamelets/src/main/resources/kamelets/elasticsearch-search-action.kamelet.yaml
@@ -0,0 +1,162 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: elasticsearch-search-action
+ labels:
+ camel.apache.org/kamelet.type: "action"
+ camel.apache.org/kamelet.verified: "true"
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1NTAgMjUwIiB2aWV3Qm94PSI3Nyw4Myw0MTAsOTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiA8cGF0aCBkPSJtMTc4IDEwMi41aDMxM3Y0MWgtMzEzeiIgZmlsbD0ibm9uZSIvPgogPGcgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyI+CiAgPHBhdGggZD0ibTE5My4zIDEzOS40Yy00IDAtNy4yLTEuMi05LjUtMy41cy0zLjQtNS42LTMuNC05LjdjMC00LjIgMS4xLTcuNiAzLjItMTBzNS0zLjYgOC43LTMuNmMzLjQgMCA2Lj
[...]
+ camel.apache.org/kamelet.group: "ElasticSearch"
+ camel.apache.org/kamelet.namespace: "Search"
+ camel.apache.org/provider: "Apache Software Foundation"
+spec:
+ definition:
+ title: "ElasticSearch Search Action"
+ description: |-
+ Searches an index of Elasticsearch for each message, and gives back the
documents found, as a JSON array.
+
+ Use it to look something up in the middle of a flow, for example to find
the customer of an order, or to enrich an event with the records that match it.
To store documents in Elasticsearch, use `elasticsearch-index-sink`; for
OpenSearch, use `opensearch-search-action`.
+
+ Input: the body is the search. Text that starts with `{` is a search in
the Query DSL of Elasticsearch, as JSON text: either a query alone, such as
`{"match": {"city": "Oslo"}}`, or the body of a `_search` request with a
`query`, such as `{"query": {"match_all": {}}, "sort": [{"age": "desc"}]}`. Any
other text is searched for as words in all the fields of the documents: `Oslo
Rome` finds the documents that contain Oslo or Rome. An empty body finds
nothing. Bytes are read as text, a [...]
+
+ Output: the body is a JSON array, as text, with the documents found
(their `_source`), best match first unless the search has a `sort`, such as
`[{"name": "Alice Smith", "city": "Oslo"}]`; an empty array `[]` when nothing
matches. The `CamelElasticsearchTotalHits` header is the number of documents
that match, which can be more than the documents in the body. The
`Content-Type` header is `application/json`.
+
+ Good to know: the body holds at most `size` documents; a `size` in the
search is ignored. Elasticsearch stops counting the matches at 10000, so a
larger number is given as 10000. A search with `"_source": false` gives an
empty array. A search that is not valid JSON, an index that does not exist, or
a query that Elasticsearch rejects, fails the message. Headers that start with
`CamelElasticsearch` are removed from the message first, so they cannot change
the index, the operation or [...]
+ required:
+ - clusterName
+ - hostAddresses
+ - indexName
+ type: object
+ properties:
+ user:
+ title: Username
+ description: The Elasticsearch user to log in as, such as `elastic`.
Leave it out for a cluster without security.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password of the Elasticsearch user in `user`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ enableSSL:
+ title: Enable SSL
+ description: If true, it connects with HTTPS. Set it to false for a
cluster that is reached with plain HTTP.
+ type: boolean
+ default: true
+ hostAddresses:
+ title: Host Addresses
+ description: The address of the Elasticsearch HTTP API, as
`host:port`, or several nodes separated by commas. The port is 9200 by default.
+ type: string
+ example: quickstart-es-http:9200
+ clusterName:
+ title: ElasticSearch Cluster Name
+ description: The name of the Elasticsearch cluster. Required, but not
checked against the cluster.
+ type: string
+ example: quickstart
+ indexName:
+ title: Index in ElasticSearch
+ description: The name of the index to search.
+ type: string
+ example: customers
+ size:
+ title: Size
+ description: The largest number of documents to give back in the body,
for each message. It takes precedence over a `size` in the search.
+ type: integer
+ default: 10
+ certificate:
+ title: Certificate
+ description: The certificate of the certificate authority (CA) that
signed the certificate of the cluster, such as the `http_ca.crt` file that
Elasticsearch generates, as a PEM or DER file encoded in base64 on one line,
such as the output of `base64 -w0 http_ca.crt` (`base64 -i http_ca.crt` on
macOS). Needed when the cluster uses a self-signed certificate, or one signed
by a private CA. When it is set, only this CA is trusted; when it is not set,
the certificates that Java trusts [...]
+ type: string
+ connectionTimeout:
+ title: Connection Timeout
+ description: How long to wait for the connection to Elasticsearch, in
milliseconds. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 5000
+ socketTimeout:
+ title: Socket Timeout
+ description: How long to wait for data from Elasticsearch, in
milliseconds. When Elasticsearch sends nothing for this long, the message
fails. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 10000
+ dataTypes:
+ # No 'default:' on purpose: the body is made text in the template. See
#3117.
+ in:
+ headers: {}
+ out:
+ headers:
+ CamelElasticsearchTotalHits:
+ title: Total Hits
+ description: 'The number of documents that match the search, counted
up to 10000. It has no value when the search sets `"track_total_hits": false`.'
+ type: integer
+ dependencies:
+ - "camel:jackson3"
+ - "camel:kamelet"
+ - "camel:elasticsearch"
+ template:
+ beans:
+ - name: local-es
+ type: "#class:org.apache.camel.component.es.ElasticsearchComponent"
+ properties:
+ user: "{{?user}}"
+ password: "{{?password}}"
+ from:
+ uri: kamelet:source
+ steps:
+ - removeHeaders:
+ pattern: "CamelElasticsearch*"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body} !is 'java.util.Map'"
+ steps:
+ - convertBodyTo:
+ type: java.lang.String
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body.trim()} !startsWith '{'"
+ steps:
+ - setBody:
+ expression:
+ simple:
+ expression: '{"query": {"multi_match":
{"query": "${escape(json)}"} } }'
+ - to:
+ uri:
"{{local-es}}:{{clusterName}}?operation=Search&indexName={{indexName}}&size={{size}}&documentClass=java.util.Map&hostAddresses={{hostAddresses}}&enableSSL={{enableSSL}}&certificatePath=RAW(base64:{{?certificate}})&connectionTimeout={{?connectionTimeout}}&socketTimeout={{?socketTimeout}}"
+ - removeHeaders:
+ pattern: "CamelElasticsearch*"
+ - setHeader:
+ name: CamelElasticsearchTotalHits
+ expression:
+ simple:
+ expression: "${body?.total.value}"
+ - setBody:
+ expression:
+ simple:
+ expression: "${forEach(${body.hits},${body.source})}"
+ - marshal:
+ json: {}
+ - convertBodyTo:
+ type: java.lang.String
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-action.kamelet.yaml
new file mode 100644
index 000000000..37b4eae15
--- /dev/null
+++
b/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-action.kamelet.yaml
@@ -0,0 +1,167 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+apiVersion: camel.apache.org/v1
+kind: Kamelet
+metadata:
+ name: opensearch-search-action
+ labels:
+ camel.apache.org/kamelet.type: "action"
+ camel.apache.org/kamelet.verified: "true"
+ annotations:
+ camel.apache.org/kamelet.support.level: "Preview"
+ camel.apache.org/catalog.version: "4.24.0-SNAPSHOT"
+ camel.apache.org/kamelet.icon:
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzNzIgNzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cjx0aXRsZT5PcGVuU2VhcmNoIGxvZ288L3RpdGxlPgo8ZGVzYz5TZWFyY2ggZW5naW5lIHNvZnR3YXJlIGZvcmsgb2YgRWxhc3RpY3NlYXJjaDwvZGVzYz4KIDxwYXRoIGQ9Im02MS43Mzc0IDI2LjVjLTEuMjQ5NiAwLTIuMjYyNiAxLjAxMy0yLjI2MjYgMi4yNjI2IDAgMTguNjE4OC0xNS4wOTM0IDMzLjcxMjItMzMuNzEyMiAzMy43MTIyLTEuMjQ5NiAwLTIuMjYyNi
[...]
+ camel.apache.org/kamelet.group: "OpenSearch"
+ camel.apache.org/kamelet.namespace: "Search"
+ camel.apache.org/provider: "Apache Software Foundation"
+spec:
+ definition:
+ title: "OpenSearch Search Action"
+ description: |-
+ Searches an index of OpenSearch for each message, and gives back the
documents found, as a JSON array.
+
+ Use it to look something up in the middle of a flow, for example to find
the customer of an order, or to enrich an event with the records that match it.
To store documents in OpenSearch, use `opensearch-index-sink`; for
Elasticsearch, use `elasticsearch-search-action`.
+
+ Input: the body is the search. Text that starts with `{` is a search in
the Query DSL of OpenSearch, as JSON text: either a query alone, such as
`{"match": {"city": "Oslo"}}`, or the body of a `_search` request with a
`query`, such as `{"query": {"match_all": {}}, "sort": [{"age": "desc"}]}`. Any
other text is searched for as words in all the fields of the documents: `Oslo
Rome` finds the documents that contain Oslo or Rome. An empty body finds
nothing. Bytes are read as text, and [...]
+
+ Output: the body is a JSON array, as text, with the documents found
(their `_source`), best match first unless the search has a `sort`, such as
`[{"name": "Alice Smith", "city": "Oslo"}]`; an empty array `[]` when nothing
matches. The `CamelOpensearchTotalHits` header is the number of documents that
match, which can be more than the documents in the body. The `Content-Type`
header is `application/json`.
+
+ Good to know: the body holds at most `size` documents; a `size` in the
search is ignored. OpenSearch stops counting the matches at 10000, so a larger
number is given as 10000. A search with `"_source": false` gives an empty
array. A search that is not valid JSON, an index that does not exist, or a
query that OpenSearch rejects, fails the message. Headers that start with
`CamelOpensearch` are removed from the message first, so they cannot change the
index, the operation or the size. [...]
+ required:
+ - clusterName
+ - hostAddresses
+ - indexName
+ type: object
+ properties:
+ user:
+ title: Username
+ description: The OpenSearch user to log in as, such as `admin`. Leave
it out for a cluster without security.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ password:
+ title: Password
+ description: The password of the OpenSearch user in `user`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ enableSSL:
+ title: Enable SSL
+ description: If true, it connects with HTTPS. Set it to false for a
cluster that is reached with plain HTTP.
+ type: boolean
+ default: true
+ hostAddresses:
+ title: Host Addresses
+ description: The address of the OpenSearch HTTP API, as `host:port`,
or several nodes separated by commas. The port is 9200 by default.
+ type: string
+ example: quickstart-es-http:9200
+ clusterName:
+ title: OpenSearch Cluster Name
+ description: The name of the OpenSearch cluster. Required, but not
checked against the cluster.
+ type: string
+ example: quickstart
+ indexName:
+ title: Index in OpenSearch
+ description: The name of the index to search.
+ type: string
+ example: customers
+ size:
+ title: Size
+ description: The largest number of documents to give back in the body,
for each message. It takes precedence over a `size` in the search.
+ type: integer
+ default: 10
+ sslContextParameters:
+ title: SSL Context Parameters
+ description: For TLS settings that `certificate` cannot give, such as
a client certificate (mutual TLS), a trust store, or a TLS version, an
`SSLContextParameters` object defined in the application, as `#bean:` followed
by its name. It takes precedence over `certificate`; set one or the other.
+ type: string
+ example: "#bean:mySslContext"
+ certificate:
+ title: Certificate
+ description: The certificate of the certificate authority (CA) that
signed the certificate of the cluster, such as the `root-ca.pem` file of the
OpenSearch demo configuration, as a PEM or DER file encoded in base64 on one
line, such as the output of `base64 -w0 root-ca.pem` (`base64 -i root-ca.pem`
on macOS). Needed when the cluster uses a self-signed certificate, or one
signed by a private CA. When it is set, only this CA is trusted; when it is not
set, the certificates that Jav [...]
+ type: string
+ connectionTimeout:
+ title: Connection Timeout
+ description: How long to wait for the connection to OpenSearch, in
milliseconds. When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 5000
+ socketTimeout:
+ title: Socket Timeout
+ description: How long to wait for data from OpenSearch, in
milliseconds. When OpenSearch sends nothing for this long, the message fails.
When it is not set, it is 30000, which is 30 seconds.
+ type: integer
+ example: 10000
+ dataTypes:
+ # No 'default:' on purpose: the body is made text in the template. See
#3117.
+ in:
+ headers: {}
+ out:
+ headers:
+ CamelOpensearchTotalHits:
+ title: Total Hits
+ description: 'The number of documents that match the search, counted
up to 10000. It has no value when the search sets `"track_total_hits": false`.'
+ type: integer
+ dependencies:
+ - "camel:jackson3"
+ - "camel:kamelet"
+ - "camel:opensearch"
+ template:
+ beans:
+ - name: local-opensearch
+ type:
"#class:org.apache.camel.component.opensearch.OpensearchComponent"
+ properties:
+ user: "{{?user}}"
+ password: "{{?password}}"
+ from:
+ uri: kamelet:source
+ steps:
+ - removeHeaders:
+ pattern: "CamelOpensearch*"
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body} !is 'java.util.Map'"
+ steps:
+ - convertBodyTo:
+ type: java.lang.String
+ - choice:
+ when:
+ - expression:
+ simple:
+ expression: "${body.trim()} !startsWith '{'"
+ steps:
+ - setBody:
+ expression:
+ simple:
+ expression: '{"query": {"multi_match":
{"query": "${escape(json)}"} } }'
+ - to:
+ uri:
"{{local-opensearch}}:{{clusterName}}?operation=Search&indexName={{indexName}}&size={{size}}&documentClass=java.util.Map&hostAddresses={{hostAddresses}}&enableSSL={{enableSSL}}&certificatePath=RAW(base64:{{?certificate}})&sslContextParameters={{?sslContextParameters}}&connectionTimeout={{?connectionTimeout}}&socketTimeout={{?socketTimeout}}"
+ - removeHeaders:
+ pattern: "CamelOpensearch*"
+ - setHeader:
+ name: CamelOpensearchTotalHits
+ expression:
+ simple:
+ expression: "${body?.total.value}"
+ - setBody:
+ expression:
+ simple:
+ expression: "${forEach(${body.hits},${body.source})}"
+ - marshal:
+ json: {}
+ - convertBodyTo:
+ type: java.lang.String
diff --git
a/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.citrus.it.yaml
new file mode 100644
index 000000000..da40314a1
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.citrus.it.yaml
@@ -0,0 +1,176 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: elasticsearch-search-action-route-test
+actions:
+ # Elasticsearch with one node and security off, so it is reached with plain
HTTP
+ - testcontainers:
+ start:
+ container:
+ name: "elasticsearch"
+ image: "elasticsearch:9.1.0"
+ startUpTimeout: 180
+ exposedPorts:
+ - 9200
+ env:
+ - name: "discovery.type"
+ value: "single-node"
+ - name: "xpack.security.enabled"
+ value: "false"
+ - name: "cluster.routing.allocation.disk.threshold_enabled"
+ value: "false"
+ - name: "ES_JAVA_OPTS"
+ value: "-Xms512m -Xmx512m"
+ waitFor:
+ url: "http://localhost:9200/"
+
+ # two customers to search, and a third one in another index, that the
Kamelet must not find
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/customers/_doc/1"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Alice Smith", "city": "Oslo"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/customers/_doc/2"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Bob Jones", "city": "Rome"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/other/_doc/3"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Carol White", "city": "Oslo"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}:${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+
+ - camel:
+ cli:
+ run:
+ waitForRunningState: false
+ integration:
+ file: "elasticsearch/elasticsearch-search-action-route.yaml"
+ systemProperties:
+ properties:
+ - name: "elasticsearch.host"
+ value: "${CITRUS_TESTCONTAINERS_ELASTICSEARCH_HOST}"
+ - name: "elasticsearch.port"
+ value: "${CITRUS_TESTCONTAINERS_ELASTICSEARCH_PORT}"
+ - name: "http.sink.url"
+ value: "http://localhost:${search.server.port}"
+
+ # a query in the Query DSL: the body is the JSON array of the documents
found, only in the index of the option
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/json"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '1'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[{"name": "Alice Smith", "city": "Oslo"}]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # plain text
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/text"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '1'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[{"name": "Bob Jones", "city": "Rome"}]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # no match: an empty array
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/none"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '0'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.yaml
new file mode 100644
index 000000000..49db72a47
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/elasticsearch/elasticsearch-search-action-route.yaml
@@ -0,0 +1,94 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "timer:tick"
+ parameters:
+ period: "1000"
+ repeatCount: 1
+ steps:
+ # a query in the Query DSL; the headers of the component on the
message are removed,
+ # so this one cannot make it search the index "other"
+ - setHeader:
+ name: CamelElasticsearchIndexName
+ constant: 'other'
+ - setBody:
+ constant: '{"match": {"city": "Oslo"}}'
+ - to:
+ uri: "kamelet:elasticsearch-search-action"
+ parameters:
+ hostAddresses: '{{elasticsearch.host}}:{{elasticsearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelElasticsearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/json"
+ # plain text: the words are searched for in all the fields
+ - setBody:
+ constant: 'Rome'
+ - to:
+ uri: "kamelet:elasticsearch-search-action"
+ parameters:
+ hostAddresses: '{{elasticsearch.host}}:{{elasticsearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelElasticsearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/text"
+ # a search request that finds nothing
+ - setBody:
+ constant: '{"query": {"match": {"city": "Paris"}}}'
+ - to:
+ uri: "kamelet:elasticsearch-search-action"
+ parameters:
+ hostAddresses: '{{elasticsearch.host}}:{{elasticsearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelElasticsearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/none"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.citrus.it.yaml
new file mode 100644
index 000000000..53702be5a
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.citrus.it.yaml
@@ -0,0 +1,178 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: opensearch-search-action-route-test
+actions:
+ # OpenSearch with one node and the security plugin off, so it is reached
with plain HTTP
+ - testcontainers:
+ start:
+ container:
+ name: "opensearch"
+ image: "opensearchproject/opensearch:3.9.0"
+ startUpTimeout: 180
+ exposedPorts:
+ - 9200
+ env:
+ - name: "discovery.type"
+ value: "single-node"
+ - name: "DISABLE_SECURITY_PLUGIN"
+ value: "true"
+ - name: "DISABLE_INSTALL_DEMO_CONFIG"
+ value: "true"
+ - name: "cluster.routing.allocation.disk.threshold_enabled"
+ value: "false"
+ - name: "OPENSEARCH_JAVA_OPTS"
+ value: "-Xms512m -Xmx512m"
+ waitFor:
+ url: "http://localhost:9200/"
+
+ # two customers to search, and a third one in another index, that the
Kamelet must not find
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/customers/_doc/1"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Alice Smith", "city": "Oslo"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/customers/_doc/2"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Bob Jones", "city": "Rome"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ sendRequest:
+ PUT:
+ path: "/other/_doc/3"
+ contentType: "application/json"
+ parameters:
+ - name: "refresh"
+ value: 'true'
+ body:
+ data: '{"name": "Carol White", "city": "Oslo"}'
+ - http:
+ client:
"http://${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}:${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ receiveResponse:
+ response:
+ status: 201
+
+ - camel:
+ cli:
+ run:
+ waitForRunningState: false
+ integration:
+ file: "opensearch/opensearch-search-action-route.yaml"
+ systemProperties:
+ properties:
+ - name: "opensearch.host"
+ value: "${CITRUS_TESTCONTAINERS_OPENSEARCH_HOST}"
+ - name: "opensearch.port"
+ value: "${CITRUS_TESTCONTAINERS_OPENSEARCH_PORT}"
+ - name: "http.sink.url"
+ value: "http://localhost:${search.server.port}"
+
+ # a query in the Query DSL: the body is the JSON array of the documents
found, only in the index of the option
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/json"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '1'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[{"name": "Alice Smith", "city": "Oslo"}]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # plain text
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/text"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '1'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[{"name": "Bob Jones", "city": "Rome"}]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
+
+ # no match: an empty array
+ - http:
+ server: "searchServer"
+ receiveRequest:
+ POST:
+ path: "/none"
+ type: "json"
+ headers:
+ - name: "X-Body-Type"
+ value: 'java.lang.String'
+ - name: "X-Total-Hits"
+ value: '0'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
+ body:
+ data: '[]'
+ - http:
+ server: "searchServer"
+ sendResponse:
+ response:
+ status: 200
+ reasonPhrase: "OK"
+ version: "HTTP/1.1"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.yaml
new file mode 100644
index 000000000..c9d3c8172
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/opensearch/opensearch-search-action-route.yaml
@@ -0,0 +1,94 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+- route:
+ from:
+ uri: "timer:tick"
+ parameters:
+ period: "1000"
+ repeatCount: 1
+ steps:
+ # a query in the Query DSL; the headers of the component on the
message are removed,
+ # so this one cannot make it search the index "other"
+ - setHeader:
+ name: CamelOpensearchIndexName
+ constant: 'other'
+ - setBody:
+ constant: '{"match": {"city": "Oslo"}}'
+ - to:
+ uri: "kamelet:opensearch-search-action"
+ parameters:
+ hostAddresses: '{{opensearch.host}}:{{opensearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelOpensearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/json"
+ # plain text: the words are searched for in all the fields
+ - setBody:
+ constant: 'Rome'
+ - to:
+ uri: "kamelet:opensearch-search-action"
+ parameters:
+ hostAddresses: '{{opensearch.host}}:{{opensearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelOpensearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/text"
+ # a search request that finds nothing
+ - setBody:
+ constant: '{"query": {"match": {"city": "Paris"}}}'
+ - to:
+ uri: "kamelet:opensearch-search-action"
+ parameters:
+ hostAddresses: '{{opensearch.host}}:{{opensearch.port}}'
+ clusterName: 'docker-cluster'
+ indexName: 'customers'
+ enableSSL: false
+ # what the Kamelet gives: the Java type of the body, the total and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Total-Hits
+ simple: "${header.CamelOpensearchTotalHits}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ - to:
+ uri: "{{http.sink.url}}/none"