This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-21976 in repository https://gitbox.apache.org/repos/asf/camel.git
commit b69d07dbd6ca2b10e8f90cd801ab5e1ea2ff9fc0 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu May 8 12:21:31 2025 +0200 CAMEL-21976 - camel-elasticsearch - Upgrade to v9 Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../org/apache/camel/component/es/ElasticsearchProducer.java | 5 ++++- .../ElasticsearchGetSearchDeleteExistsUpdateIT.java | 10 +++++----- parent/pom.xml | 4 ++-- .../test/infra/elasticsearch/services/container.properties | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java index c00bcd61bc0..0e57044b94f 100644 --- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java +++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java @@ -47,6 +47,7 @@ import co.elastic.clients.elasticsearch.indices.ExistsRequest; import co.elastic.clients.json.jackson.JacksonJsonpMapper; import co.elastic.clients.transport.ElasticsearchTransport; import co.elastic.clients.transport.endpoints.BooleanResponse; +import co.elastic.clients.transport.rest_client.RestClientOptions; import co.elastic.clients.transport.rest_client.RestClientTransport; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -62,6 +63,7 @@ import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.sniff.Sniffer; @@ -140,7 +142,8 @@ class ElasticsearchProducer extends DefaultAsyncProducer { } final ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper(mapper)); + RestClientOptions options = new RestClientOptions(RequestOptions.DEFAULT, true); + ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper(mapper), options); // 2. Index and type will be set by: // a. If the incoming body is already an action request // b. If the body is not an action request we will use headers if they diff --git a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchGetSearchDeleteExistsUpdateIT.java b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchGetSearchDeleteExistsUpdateIT.java index c79fd106865..2adcbeb1a5c 100644 --- a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchGetSearchDeleteExistsUpdateIT.java +++ b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchGetSearchDeleteExistsUpdateIT.java @@ -36,10 +36,10 @@ import co.elastic.clients.elasticsearch.core.MsearchRequest; import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.mget.MultiGetResponseItem; import co.elastic.clients.elasticsearch.core.msearch.MultiSearchResponseItem; -import co.elastic.clients.elasticsearch.core.msearch.MultisearchBody; import co.elastic.clients.elasticsearch.core.msearch.MultisearchHeader; import co.elastic.clients.elasticsearch.core.msearch.RequestItem; import co.elastic.clients.elasticsearch.core.search.HitsMetadata; +import co.elastic.clients.elasticsearch.core.search.SearchRequestBody; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -448,9 +448,9 @@ class ElasticsearchGetSearchDeleteExistsUpdateIT extends ElasticsearchTestSuppor //now, verify GET succeeded MsearchRequest.Builder builder = new MsearchRequest.Builder().index("twitter").searches( new RequestItem.Builder().header(new MultisearchHeader.Builder().build()) - .body(new MultisearchBody.Builder().query(b -> b.matchAll(x -> x)).build()).build(), + .body(new SearchRequestBody.Builder().query(b -> b.matchAll(x -> x)).build()).build(), new RequestItem.Builder().header(new MultisearchHeader.Builder().build()) - .body(new MultisearchBody.Builder().query(b -> b.matchAll(x -> x)).build()).build()); + .body(new SearchRequestBody.Builder().query(b -> b.matchAll(x -> x)).build()).build()); @SuppressWarnings("unchecked") List<MultiSearchResponseItem<?>> response = template.requestBody("direct:multiSearch", builder, List.class); assertNotNull(response, "response should not be null"); @@ -484,9 +484,9 @@ class ElasticsearchGetSearchDeleteExistsUpdateIT extends ElasticsearchTestSuppor //now, verify GET succeeded MsearchRequest.Builder builder = new MsearchRequest.Builder().index("multi-search").searches( new RequestItem.Builder().header(new MultisearchHeader.Builder().build()) - .body(new MultisearchBody.Builder().query(b -> b.matchAll(x -> x)).build()).build(), + .body(new SearchRequestBody.Builder().query(b -> b.matchAll(x -> x)).build()).build(), new RequestItem.Builder().header(new MultisearchHeader.Builder().build()) - .body(new MultisearchBody.Builder().query(b -> b.matchAll(x -> x)).build()).build()); + .body(new SearchRequestBody.Builder().query(b -> b.matchAll(x -> x)).build()).build()); @SuppressWarnings("unchecked") List<MultiSearchResponseItem<?>> response = template.requestBodyAndHeaders( "direct:multiSearch", builder, diff --git a/parent/pom.xml b/parent/pom.xml index 02009443bcc..f59161362f3 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -146,8 +146,8 @@ <eddsa-version>0.3.0</eddsa-version> <egit-github-core-version>2.1.5</egit-github-core-version> <ehcache3-version>3.10.8</ehcache3-version> - <elasticsearch-java-client-version>8.17.4</elasticsearch-java-client-version> - <elasticsearch-java-client-sniffer-version>8.17.4</elasticsearch-java-client-sniffer-version> + <elasticsearch-java-client-version>9.0.1</elasticsearch-java-client-version> + <elasticsearch-java-client-sniffer-version>9.0.1</elasticsearch-java-client-sniffer-version> <elytron-web>4.1.2.Final</elytron-web> <extjwnl-version>2.0.5</extjwnl-version> <extjwnl-data-wn31-version>1.2</extjwnl-data-wn31-version> diff --git a/test-infra/camel-test-infra-elasticsearch/src/main/resources/org/apache/camel/test/infra/elasticsearch/services/container.properties b/test-infra/camel-test-infra-elasticsearch/src/main/resources/org/apache/camel/test/infra/elasticsearch/services/container.properties index 1b7a0233f70..e9ec0ebcb73 100644 --- a/test-infra/camel-test-infra-elasticsearch/src/main/resources/org/apache/camel/test/infra/elasticsearch/services/container.properties +++ b/test-infra/camel-test-infra-elasticsearch/src/main/resources/org/apache/camel/test/infra/elasticsearch/services/container.properties @@ -14,5 +14,5 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- -elasticsearch.container=docker.elastic.co/elasticsearch/elasticsearch:8.17.4 +elasticsearch.container=docker.elastic.co/elasticsearch/elasticsearch:9.0.1 elasticsearch.container.ppc64le=icr.io/ppc64le-oss/elasticsearch-ppc64le:8.3.3