跳到主要内容
版本:6.1.1

从 4.0.x 升级到 4.1.x

Doubao 中英对照 Upgrading from 4.0.x to 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

自第 6 版起,Elasticsearch 已移除 parent-id 的使用。我们现在弃用相应的字段和方法。

移除项​

类型映射

@Document 注解和 IndexCoordinates 对象的 类型映射 参数已被移除。它们在 Spring Data Elasticsearch 4.0 中已被弃用,且其值不再被使用。

破坏性变更​

ReactiveElasticsearchClient.Indices 方法的返回类型​

ReactiveElasticsearchClient.Indices 中的方法此前一直未被使用。随着 ReactiveIndexOperations 的引入,有必要更改其中一些方法的返回类型:

  • createIndex 的各个变体现在返回 Mono<Boolean> 而非 Mono<Void>,以表示索引创建成功。

  • updateMapping 的各个变体现在返回 Mono<Boolean> 而非 Mono<Void>,以表示映射存储成功。

DocumentOperations.bulkIndex 方法的返回类型​

这些方法过去返回一个 List<String>,其中包含新索引记录的 id。现在它们返回 List<IndexedObjectInformation>;这些对象包含 id 以及有关乐观锁的信息(seq_no 和 primary_term)。