Polishing.

Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
This commit is contained in:
Peter-Josef Meisch 2025-05-29 18:10:48 +02:00
parent 158f5fc342
commit a9d2aaa93d
No known key found for this signature in database
GPG Key ID: DE108246970C7708
7 changed files with 269 additions and 212 deletions

View File

@ -12,6 +12,7 @@
*** xref:migration-guides/migration-guide-5.2-5.3.adoc[]
*** xref:migration-guides/migration-guide-5.3-5.4.adoc[]
*** xref:migration-guides/migration-guide-5.4-5.5.adoc[]
*** xref:migration-guides/migration-guide-5.5-6.0.adoc[]
* xref:elasticsearch.adoc[]

View File

@ -1,6 +1,14 @@
[[new-features]]
= What's new
[[new-features.6-0-0]]
== New in Spring Data Elasticsearch 6.6
* Upgarde to Spring 7
* Switch to jspecify nullability annotations
* Upgrade to Elasticsearch 9.0.1
[[new-features.5-5-0]]
== New in Spring Data Elasticsearch 5.5

View File

@ -6,7 +6,7 @@ The following table shows the Elasticsearch and Spring versions that are used by
[cols="^,^,^,^",options="header"]
|===
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework
| 2025.1 (in development) | 6.0.x | 8.18.1 | 7.0.x
| 2025.1 (in development) | 6.0.x | 9.0.1 | 7.0.x
| 2025.0 | 5.5.x | 8.18.1 | 6.2.x
| 2024.1 | 5.4.x | 8.15.5 | 6.1.x
| 2024.0 | 5.3.xfootnote:oom[Out of maintenance] | 8.13.4 | 6.1.x

View File

@ -0,0 +1,21 @@
[[elasticsearch-migration-guide-5.5-6.0]]
= Upgrading from 5.5.x to 6.0.x
This section describes breaking changes from version 5.5.x to 6.0.x and how removed features can be replaced by new introduced features.
[[elasticsearch-migration-guide-5.5-6.0.breaking-changes]]
== Breaking Changes
[[elasticsearch-migration-guide-5.5-6.0.deprecations]]
== Deprecations
=== Removals
The `org.springframework.data.elasticsearch.core.query.ScriptType` enum has been removed. To distinguish between an inline and a stored script set the appropriate values in the `org.springframework.data.elasticsearch.core.query.ScriptData` record.
These methods have been removed because the Elasticsearch Client 9 does not support them anymore:
```
org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.unfreeze(UnfreezeRequest)
org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchIndicesClient.unfreeze(Function<UnfreezeRequest.Builder, ObjectBuilder<UnfreezeRequest>>)
```

View File

@ -24,14 +24,6 @@ import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.elasticsearch.core.search.NestedIdentity;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpMapper;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
@ -44,6 +36,13 @@ import org.springframework.data.elasticsearch.core.document.SearchDocumentAdapte
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import org.springframework.util.Assert;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Utility class to adapt different Elasticsearch responses to a
* {@link org.springframework.data.elasticsearch.core.document.Document}
@ -57,7 +56,8 @@ final class DocumentAdapters {
private static final Log LOGGER = LogFactory.getLog(DocumentAdapters.class);
private DocumentAdapters() {}
private DocumentAdapters() {
}
/**
* Creates a {@link SearchDocument} from a {@link Hit} returned by the Elasticsearch client.

View File

@ -15,24 +15,36 @@
*/
package org.springframework.data.elasticsearch.core.query;
import java.util.Map;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import java.util.Map;
import java.util.function.Function;
/**
* value class combining script information.
* <p>
* A script is either an inline script, then the script parameters must be set
* or it refers to a stored script, then the name parameter is required.
*
* @param language the language when the script is passed in the script parameter
* @param script the script to use as inline script
* @param scriptName the name when using a stored script
* @param params the script parameters
* @author Peter-Josef Meisch
* @since 4.4
*/
public record ScriptData(@Nullable String language, @Nullable String script,
@Nullable String scriptName, @Nullable Map<String, Object> params) {
/*
* constructor overload to check the parameters
*/
public ScriptData(@Nullable String language, @Nullable String script, @Nullable String scriptName,
@Nullable Map<String, Object> params) {
Assert.isTrue(script != null || scriptName != null, "script or scriptName is required");
this.language = language;
this.script = script;
this.scriptName = scriptName;
@ -40,6 +52,8 @@ public record ScriptData(@Nullable String language, @Nullable String script,
}
/**
* factory method to create a ScriptData object.
*
* @since 5.2
*/
public static ScriptData of(@Nullable String language, @Nullable String script,
@ -47,9 +61,15 @@ public record ScriptData(@Nullable String language, @Nullable String script,
return new ScriptData(language, script, scriptName, params);
}
/**
* factory method to create a ScriptData object using a ScriptBuilder callback.
*
* @param builderFunction function called to populate the builder
* @return
*/
public static ScriptData of(Function<Builder, Builder> builderFunction) {
Assert.notNull(builderFunction, "f must not be null");
Assert.notNull(builderFunction, "builderFunction must not be null");
return builderFunction.apply(new Builder()).build();
}
@ -65,12 +85,17 @@ public record ScriptData(@Nullable String language, @Nullable String script,
* @since 5.2
*/
public static final class Builder {
@Nullable private String language;
@Nullable private String script;
@Nullable private String scriptName;
@Nullable private Map<String, Object> params;
@Nullable
private String language;
@Nullable
private String script;
@Nullable
private String scriptName;
@Nullable
private Map<String, Object> params;
private Builder() {}
private Builder() {
}
public Builder withLanguage(@Nullable String language) {
this.language = language;
@ -93,7 +118,6 @@ public record ScriptData(@Nullable String language, @Nullable String script,
}
public ScriptData build() {
return new ScriptData(language, script, scriptName, params);
}
}

View File

@ -28,6 +28,7 @@ public record Script(String id, String language, String source) {
Assert.notNull(id, "id must not be null");
Assert.notNull(language, "language must not be null");
Assert.notNull(source, "source must not be null");
}
public static ScriptBuilder builder() {
@ -60,6 +61,8 @@ public record Script(String id, String language, String source) {
public ScriptBuilder withSource(String source) {
Assert.notNull(source, "source must not be null");
this.source = source;
return this;
}