从 5.0.x 升级到 5.1.x
本节描述了从版本 5.0.x 到 5.1.x 的重大变更,以及如何用新引入的功能替换已移除的功能。
重大变更
在 org.springframework.data.elasticsearch.core.index.AliasData
类中,用于从 Elasticsearch 返回的别名信息的属性 filter
(类型为 Document
)已被替换为 filterQuery
,其类型为 org.springframework.data.elasticsearch.core.query.Query
。
org.springframework.data.elasticsearch.annotations.Similarity
在 5.1 版本之前是一个枚举类。该枚举类用于 @Field
注解中,以指定相似度值。但除了枚举定义的值之外,Elasticsearch 中还可以使用自定义名称的相似度。因此,注解属性从枚举类型更改为简单的 String
类型。之前的枚举值如 Similarity.Default
仍然以字符串常量的形式存在,因此现有代码无需修改即可编译。如果该枚举在 @Field
注解之外的其他地方使用,则需要进行适配。
弃用
模板函数
IndexOperations
和 ReactiverIndexOperations
中用于管理索引模板的函数在 Spring Data Elasticsearch 4.1 中已被弃用。这些函数使用了在 Elasticsearch 7.8 版本中被弃用的旧 Elasticsearch API。
请改用基于可组合索引模板 API 的新函数。