我可以使用旧的 spring-data-elasticsearch 连接到新的 elasticsearch 吗?

发布于 2025-01-16 20:58:51 字数 1540 浏览 2 评论 0原文

目前我们使用的是 spring-data-elasticsearch 3.2.6 + elasticsearch 6.8。 我们正在转向新的 elasticsearch 7.x。我必须将 spring-data-elasticsearch 更新到 4.x 吗?我们只在 spring-data-elasticsearch 中使用 ElasticsearchRepository。而且我们不需要使用elasticsearch 7.x中的任何新功能。

如果我们将来迁移到 elasticsearch 8.x,我需要更新 spring-data-elasticsearch 吗?

更新

什么Spring-Data-Elasticsearch 在底层使用 Elasticsearch 客户端吗?

`ElasticsearchRepository` 中的所有方法均已弃用。我应该使用什么?

我在上面的帖子中找到了一些讨论。这是我的总结。

  1. 模板操作:

ElasticsearchTemplate 实现 ElasticSearchOperation。它使用 TransportClient(在 ES 7 中已弃用,并已在 ES8 中删除)

ElasticsearchRestTemplate 实现 ElasticSearchOperation。它使用高级客户端(在 ES 7.16.0 中已弃用。将来它将被删除。@Deprecated(since = "7.16.0", forRemoval = true) )

ReactiveElasticsearchTemplate 实现 ReactiveElasticsearchOperations。它使用反应式客户端。

  1. 存储库

ElasticsearchRepository 默认使用 TransportClient。 ElasticsearchRepository 中的所有方法现已弃用。

Reactive Elasticsearch 存储库基于 ReactiveElasticsearchOperations 构建。


由于底层 TransportClient 或 HigLevelRestClient 已被弃用,我是否可以得出结论,正确的方法是使用 Reactive Client(ReactiveElasticsearchTemplate 或 Reactive Elasticsearch 存储库)?

Currently we are on spring-data-elasticsearch 3.2.6 + elasticsearch 6.8.
We are moving to new elasticsearch 7.x. Do I have to update spring-data-elasticsearch to 4.x? We only use ElasticsearchRepository in spring-data-elasticsearch. And we don't need to use any new feature in elasticsearch 7.x.

If we are moving to elasticsearch 8.x in the future, do I need update spring-data-elasticsearch ?

Update:

What Elasticsearch client does Spring-Data-Elasticsearch use under the hood?

All methods in the `ElasticsearchRepository` are deprecated. What should do I use?

I found some discussions in above threads. Here is my summary.

  1. Operations with Templates:

ElasticsearchTemplate implements ElasticSearchOperation. It uses TransportClient(which is deprecated in ES 7 and has been removed in ES8)

ElasticsearchRestTemplate implements ElasticSearchOperation. It uses high level client(which is deprecated in ES 7.16.0. It will be removed in future. @Deprecated(since = "7.16.0", forRemoval = true) )

ReactiveElasticsearchTemplate implements ReactiveElasticsearchOperations. It uses Reactive Client.

  1. Repository

ElasticsearchRepository uses TransportClient as default. All methods in the ElasticsearchRepository are deprecated now.

Reactive Elasticsearch repository builds on ReactiveElasticsearchOperations.


Due to underlying TransportClient or HigLevelRestClient has been deprecated, can I conclude that the correct way is to use Reactive Client(ReactiveElasticsearchTemplate or Reactive Elasticsearch repository) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双马尾 2025-01-23 20:58:51

Elasticsearch 将是 8。Val

已经在他的评论中添加了兼容性矩阵的链接。

版本 3.2.6 已经过时了(2020 年 3 月 25 日),并且自 2020 年 10 月起不再支持。

您可以尝试的第一件事是查看您的应用程序是否适用于 7 集群 - 尽管我对此表示怀疑,但我无法确切地告诉您API 发生了哪些变化,但还是有很多东西。

您不应该做的是将比 Spring Data Elasticsearch 构建所用的库更新的 Elasticsearch 库放在类路径上,这在大多数情况下会产生问题。

但我建议无论如何升级您的应用程序并定期保持最新状态。

至于将来升级到版本 8:可以在请求中发送兼容性标头(这可以在 Spring Data Elasticsearch 4 中完成),并且 Elasticsearch 集群应该以与期望版本 7 的客户端兼容的格式进行响应。写应该,因为它并不在每种情况下都符合这一点 - 我报告了一个现在已修复的情况。但我不会依赖于此。

再次强调,请更新您的应用程序并使其保持最新,这不仅是因为 Spring Data Elasticsearch,还因为这些更新始终包含错误和/或安全修复。

The new Elasticsearch would be 8.

Val already put the link to the compatibility matrix in his comment.

Version 3.2.6 is pretty outdated (March 25 2020) and out of support since October 2020.

The first thing you can try is to see if your application works with a 7 cluster - although I doubt that, I can't tell you exactly what had changed in the API, but there was quite some stuff.

What you should not do is putting newer Elasticsearch libraries on the classpath than the ones that Spring Data Elasticsearch was built with, this will in most cases make problems.

But I'd recommend to upgrade your application anyway and keep it regularly up to date.

As for future upgrade to version 8: It is possible to send a compatibility header in your requests (this can be done in Spring Data Elasticsearch 4) and the Elasticsearch cluster should respond in a format that is compatible with a client expecting version 7. I wrote should, because it does not conform to this in every case - I reported one case that is fixed now. But I wouldn't rely on that.

Again, please update your application and keep it up to date, not only because of Spring Data Elasticsearch, but also because these updates always include bug and/or security fixes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文