从 4.0.x 升级到 4.1.x
本节描述了从版本 4.0.x 到 4.1.x 的重大变更,以及如何通过新引入的功能来替换已移除的功能。
弃用
id 属性的定义
可以通过将实体的一个属性命名为 id 或 document 来将其定义为 id 属性。这种行为现在已被弃用,并且会产生警告。请使用 @Id 注解来标记一个属性作为 id 属性。
索引映射
在 ReactiveElasticsearchClient.Indices 接口中,updateMapping 方法已被弃用,推荐使用 putMapping 方法。它们的功能相同,但 putMapping 与 Elasticsearch API 中的命名保持一致:
别名处理
在 IndexOperations 接口中,方法 addAlias(AliasQuery)、removeAlias(AliasQuery) 和 queryForAlias() 已被弃用。新的方法 alias(AliasAction)、getAliases(String…) 和 getAliasesForIndex(String…) 提供了更多的功能和更简洁的 API。
父级 ID
自 Elasticsearch 6 版本起,parent-id 的使用已被移除。我们现在弃用相应的字段和方法。
移除内容
类型映射
@Document 注解和 IndexCoordinates 对象中的 type mappings 参数已被移除。这些参数在 Spring Data Elasticsearch 4.0 中已被弃用,并且它们的值不再被使用。
重大变更
ReactiveElasticsearchClient.Indices 方法的返回类型
到目前为止,ReactiveElasticsearchClient.Indices 中的方法尚未被使用。随着 ReactiveIndexOperations 的引入,有必要更改一些返回类型:
-
createIndex变体现在返回Mono<Boolean>而不是Mono<Void>,以表示索引创建成功。 -
updateMapping变体现在返回Mono<Boolean>而不是Mono<Void>,以表示映射存储成功。
DocumentOperations.bulkIndex 方法的返回类型
这些方法原本返回一个包含新索引记录 ID 的 List<String>。现在它们返回一个 List<IndexedObjectInformation>;这些对象包含 ID 以及关于乐观锁的信息(seq_no 和 primary_term)。