从 5.1.x 升级到 5.2.x
本节介绍从 5.1.x 版本到 5.2.x 版本的破坏性变更,以及如何用新引入的特性替代被移除的特性。
破坏性变更
批量失败
在 org.springframework.data.elasticsearch.BulkFailureException 类中,getFailedDocuments 的返回类型已从 Map<String, String> 更改为 Map<String, FailureDetails>,从而可以获取有关失败原因的更多详细信息。
FailureDetails 类(作为 BulkFailureException 的内部类)的定义如下:
public record FailureDetails(Integer status, String errorMessage) {
}
脚本化字段与运行时字段
类 org.springframework.data.elasticsearch.core.RuntimeField 和 org.springframework.data.elasticsearch.core.query.ScriptType 已移至子包 org.springframework.data.elasticsearch.core.query。
ScriptData 构造方法的 type 参数不再可为 null。
弃用项
移除已弃用的代码
-
所有使用旧的已弃用
RestHighLevelClient的代码均已被移除。自 5.0 版本起使用的默认 Elasticsearch 客户端是(不算太新的)新 Elasticsearch Java 客户端。 -
org.springframework.data.elasticsearch.client.ClientLogger类已被移除。该日志记录器通过org.springframework.data.elasticsearch.client.WIRE设置进行配置,但并非对所有客户端都有效。自第 5 版起,请使用 Elasticsearch Java 客户端中提供的 trace 日志记录器,请参阅客户端日志记录。 -
方法
org.springframework.data.elasticsearch.core.ElasticsearchOperations.stringIdRepresentation(Object)已被移除,请改用同一接口中定义的convertId(Object)方法。 -
类
org.springframework.data.elasticsearch.core.Range已被移除,请改用org.springframework.data.domain.Range。 -
方法
org.springframework.data.elasticsearch.core.query.IndexQuery.getParentId()和setParentId(String)已被移除,它们不再被使用,且为空操作。它也已从org.springframework.data.elasticsearch.core.query.IndexQuery类中移除。