diff --git a/docs/reference/setup/connecting.md b/docs/reference/setup/connecting.md index a8c3e5a4f..159f8fa79 100644 --- a/docs/reference/setup/connecting.md +++ b/docs/reference/setup/connecting.md @@ -8,7 +8,7 @@ mapped_pages: The Java API Client is structured around three main components: * **API client classes**. These provide strongly typed data structures and methods for {{es}} APIs. Since the {{es}} API is large, it is structured in feature groups (also called “namespaces”), each having its own client class. {{es}} core features are implemented in the `ElasticsearchClient` class. -* **A JSON object mapper**. This maps your application classes to JSON and seamlessly integrates them with the API client. The default implementation uses Jackson. +* **A JSON object mapper**. This maps your application classes to JSON and seamlessly integrates them with the API client. The default implementation uses Jackson version 2. * **A transport layer implementation**. This is where all HTTP request handling takes place. The [default implementation](/reference/transport/rest5-client/index.md) is based on the [Apache http client library](https://hc.apache.org/). This code snippet uses the default configurations and only needs the location and credentials to connect to Elasticsearch: diff --git a/docs/reference/transport/index.md b/docs/reference/transport/index.md index afcd049ab..309409ea5 100644 --- a/docs/reference/transport/index.md +++ b/docs/reference/transport/index.md @@ -14,6 +14,7 @@ navigation_title: Transport layer The Java API client comes with two JSON mapping implementations: * `JacksonJsonpMapper`, the default implementation based on the popular [Jackson](https://github.com/FasterXML/jackson) library. +* `Jackson3JsonpMapper`, based on the new [Jackson](https://github.com/FasterXML/jackson) library version 3. * `JsonbJsonpMapper`, based on the JakartaEE JSONP specification, which allows using any implementation of this specification such as [Eclipse Parsson](https://github.com/eclipse-ee4j/parsson) Which implementation should you use? diff --git a/docs/release-notes/9-2-0.md b/docs/release-notes/9-2-0.md new file mode 100644 index 000000000..6ebe963b5 --- /dev/null +++ b/docs/release-notes/9-2-0.md @@ -0,0 +1,112 @@ +--- +navigation_title: "9.2.0" +--- +# Elasticsearch Java Client 9.2.0 [elasticsearch-java-client-920] + +Discover what changed in the 9.2.0 version of the Java client. + +## Breaking changes [elasticsearch-java-client-920-breaking-changes] + +::::{dropdown} Map to NamedValue CompositeAggregation.sources +`sources` in `CompositeAggregation` was wrongly mapped as `List`, but the server doesn't actually accept more than one value, so the type has been changed to `List`. + +**Action**
Change the builder to use the correct type. +Example: +- Old + ```java + esClient.search(s -> s + .aggregations("agg", a -> a + .composite(c -> c + .sources(Map.of("source", CompositeAggregationSource.of(cas -> cas...)))) + ) + ); + ``` +- New + ```java + esClient.search(s -> s + .aggregations("agg", a -> a + .composite(c -> c + .sources(NamedValue.of("source", CompositeAggregationSource.of(cas -> cas...)))) + ) + ); + ``` + +:::: + +::::{dropdown} String to Double GetOverallBucketsRequest.overallScore +`overallScore` in `GetOverallBucketsRequest` was wrongly mapped as `String`, but the correct value to be sent to the server is `Double`, so the type has been changed to `Double`. + +**Action**
Change the builder to use the correct type. +Example: +- Old + ```java + esClient.ml() + .getOverallBuckets(b -> b + .overallScore("2") + ... + ); + ``` +- New + ```java + esClient.ml() + .getOverallBuckets(b -> b + .overallScore(2D) + ... + ); + ``` +:::: + +::::{dropdown} Level to NodeStatsLevel NodesStatsRequest.level +`level` in `NodesStatsRequest` was wrongly mapped as the `Level` enum, which did not match the values accepted by the server, so it has been replaced with `NodeStatsLevel`. + +**Action**
Change the builder to use the correct enum. +Example: +- Old + ```java + esClient.nodes() + .stats(s -> s + .level(Level.Indices) + ); + ``` +- New + ```java + esClient.nodes() + .stats(s -> s + .level(NodeStatsLevel.Indices) + ); + ``` +:::: + +::::{dropdown} TimeUnit to Time StreamsStatusRequest.masterTimeout +`masterTimeout` in `StreamsStatusRequest` was wrongly mapped as `TimeUnit`, but the correct value to be sent to the server is `Time`, so the type has been changed to `Time`. + +**Action**
Change the builder to use the correct type. +Example: +```java +esClient.streams() + .status(s -> s + .masterTimeout(Time.of(t -> t.time("10s"))) + ); +``` +:::: + + +## Features and enhancements [elasticsearch-java-client-920-features-enhancements] + +::::{dropdown} Jackson 3 implementation of the JSON object mapper +Following the stable release of the [Jackson library version 3](https://github.com/FasterXML/jackson/wiki/Jackson-Release-3.0), the Jackson 3 implementation of object mapper is now available! +The default implementation will stay version 2 for now, so to try the new implementation replace `JacksonJsonpMapper` with `Jackson3JsonpMapper`. +Example with shortcut builder: +```java +try (ElasticsearchClient client = ElasticsearchClient.of(e -> e + .jsonMapper(new Jackson3JsonpMapper()) + .host("your-host") + .apiKey("your-api-keys"))) { + ... +} +``` +:::: + +## Deprecations [elasticsearch-java-client-920-deprecations] + +Nothing was deprecated in this version of the client. diff --git a/docs/release-notes/index.md b/docs/release-notes/index.md index 0a3b7bcfb..d762c3aea 100644 --- a/docs/release-notes/index.md +++ b/docs/release-notes/index.md @@ -12,6 +12,9 @@ To check for security updates, refer to [Security announcements for the Elastic To check for issues, refer to [Known issues](../release-notes/known-issues.md). +## 9.2.0 +[Release notes](../release-notes/9-2-0.md) + ## 9.1.0 [Release notes](../release-notes/9-1-0.md) diff --git a/docs/release-notes/toc.yml b/docs/release-notes/toc.yml index f071ce447..4be37c090 100644 --- a/docs/release-notes/toc.yml +++ b/docs/release-notes/toc.yml @@ -1,6 +1,7 @@ toc: - file: index.md - file: known-issues.md + - file: 9-2-0.md - file: 9-1-0.md - file: 9-0-4.md - file: 9-0-0.md diff --git a/rest5-client/src/main/java/co/elastic/clients/transport/rest5_client/low_level/Rest5Client.java b/rest5-client/src/main/java/co/elastic/clients/transport/rest5_client/low_level/Rest5Client.java index 6823b7c00..be2ec04e3 100644 --- a/rest5-client/src/main/java/co/elastic/clients/transport/rest5_client/low_level/Rest5Client.java +++ b/rest5-client/src/main/java/co/elastic/clients/transport/rest5_client/low_level/Rest5Client.java @@ -276,12 +276,16 @@ public boolean isRunning() { * exception this isn't always possible and likely haven't covered all of * the cases. You can get the original exception from * {@link Exception#getCause()}. + *

+ * Differently from the legacy RestClient, this method does not throw exception + * in case of 4xx errors from the server, since often the server returns 4xx exceptions with + * bodies as part of the standard workflow. * * @param request the request to perform * @return the response returned by Elasticsearch * @throws IOException in case of a problem or the connection was aborted * @throws ClientProtocolException in case of an http protocol error - * @throws ResponseException in case Elasticsearch responded with a status code that indicated an + * @throws ResponseException in case Elasticsearch responded with a 5xx status code that indicated an * error */ public Response performRequest(Request request) throws IOException {