|
| 1 | +--- |
| 2 | +navigation_title: "9.1.0" |
| 3 | +--- |
| 4 | +# Elasticsearch Java Client 9.1.0 [elasticsearch-java-client-910] |
| 5 | + |
| 6 | +Discover what changed in the 9.1.0 version of the Java client. |
| 7 | + |
| 8 | +### Breaking changes [elasticsearch-java-client-910-breaking-changes] |
| 9 | + |
| 10 | +::::{dropdown} Map to NamedValue Highlight.fields |
| 11 | +`fields` in `Highlight` was wrongly mapped as `List<Map>`, but the server doesn't actually accept more than one value, so the type has been changed to `List<NamedValue>`. |
| 12 | + |
| 13 | +**Action**<br> Change the builder to use the correct type. |
| 14 | +Example with `SearchRequest`: |
| 15 | +- Old |
| 16 | + ```java |
| 17 | + esClient.search(s -> s |
| 18 | + .index("*") |
| 19 | + .highlight(h -> h |
| 20 | + .fields(Map.of("highlighter-field", HighlightField.of(hf -> hf...))) |
| 21 | + ) |
| 22 | + ,Void.class); |
| 23 | + ``` |
| 24 | +- New |
| 25 | + ```java |
| 26 | + esClient.search(s -> s |
| 27 | + .index("*") |
| 28 | + .highlight(h -> h |
| 29 | + .fields(NamedValue.of("highlighter-field", HighlightField.of(hf -> hf...))) |
| 30 | + ) |
| 31 | + ,Void.class); |
| 32 | + ``` |
| 33 | + |
| 34 | +:::: |
| 35 | + |
| 36 | +::::{dropdown} Map to List<Map> WeightedTokensQuery.tokens |
| 37 | +`tokens` in `WeightedTokensQuery` was mapped as `Map`, but the server can actually accept more than one map, so the type has been changed to `List<Map>`. |
| 38 | + |
| 39 | +**Action**<br> Nothing should be changed since the builders for List also accept a single value. |
| 40 | +:::: |
| 41 | + |
| 42 | +:::: |
| 43 | + |
| 44 | +::::{dropdown} Class name change: IndicesBlockStatus -> AddIndicesBlockStatus in AddBlockResponse |
| 45 | +`IndicesBlockStatus` was renamed to `AddIndicesBlockStatus` to avoid confusion with the new `RemoveIndicesBlockStatus` |
| 46 | + |
| 47 | +**Action**<br> Replace the missing class with the new class name. |
| 48 | +:::: |
| 49 | + |
| 50 | +### Features and enhancements [elasticsearch-java-client-910-features-enhancements] |
| 51 | + |
| 52 | +::::{dropdown} Opentelemetry update to stable conventions |
| 53 | +Following the stable release of Opentelemetry's database conventions, the client was updated to use the correct attribute names. |
| 54 | +More details in the PR: https://github.com/elastic/elasticsearch-java/pull/1017 |
| 55 | +:::: |
| 56 | +
|
| 57 | +::::{dropdown} GetAliasResponse exception bug fix |
| 58 | +`GetAliasesResponse` is a special case because it can return both an exception and the actual response, in case 2 aliases, 1 present and 1 missing, are added to `GetAliasesRequest`. The java client was unable to parse the response and used to throw a `TransportException`, this was fixed by adding the additional alias information to the `metadata` field in `ErrorCause`: |
| 59 | +```java |
| 60 | +try{ |
| 61 | + client.indices().getAlias(a -> a.name("test","test2")); |
| 62 | +} |
| 63 | +catch (ElasticsearchException e){ |
| 64 | + Map<String, JsonData> metadata = e.error().metadata(); |
| 65 | + JsonData index = metadata.get("example-index"); |
| 66 | + Map aliases = index.to(Map.class); |
| 67 | + assertEquals("test", aliases.keySet().iterator().next()); |
| 68 | +} |
| 69 | +``` |
| 70 | +More details in the PR: https://github.com/elastic/elasticsearch-java/pull/1041 |
| 71 | +:::: |
| 72 | +
|
| 73 | +### Deprecations [elasticsearch-java-client-910-deprecations] |
| 74 | +
|
| 75 | +Nothing was deprecated in this version of the client. |
0 commit comments