1

Getting the below error while running spring boot version 3.0.0 application with elastic search.

 Caused by: org.elasticsearch.ElasticsearchStatusException:
 Elasticsearch exception [type=exception, reason=Content-Type header [application/vnd.elasticsearch+json; compatible-with=7] is not supported]

I am trying to upgrade springboot from 2.6.9 to 3.0.x, which resulted in the above error for elastic search. (Prior to spring boot upgrade elasticsearch was working fine)

Version used before spring-boot upgrade

  • spring boot version 2.6.9
  • spring-boot-starter-data-elasticsearch 2.6.9
  • spring-data-elasticsearch 4.4.0
  • elasticsearch-rest-high-level-client 7.17.3
  • elasticsearch server version 7.9.3

Version used after spring-boot upgrade

  • spring boot version 3.0.0
  • spring-boot-starter-data-elasticsearch 3.0.0
  • spring-data-elasticsearch 5.0.0
  • elasticsearch-rest-high-level-client 7.17.3
  • elasticsearch server version 7.9.3
6
  • did you set the header in the old version as well? Commented Feb 23, 2023 at 14:41
  • No I didn't and I am not setting headers manually in this version either. Commented Feb 24, 2023 at 4:13
  • I suppose the rest-high-level-client uses the elasticsearch-low-level client in version 8.6 which adds this header. This header was introduced with 7.10 i f I remember correctly. Try to fix the version of the org.elasticsearch.restclient dependency to 7.17.3 as well. Or upgrade your cluster to 8, the RestHighLevelClient is deprecated for over a year now. Commented Feb 24, 2023 at 18:21
  • I have low level rest-client also on version 7.17.3 and it still gives the same error. Upgrading the cluster is not an option for me that is handled by different team. Commented Feb 27, 2023 at 6:58
  • One interesting thing to note here is that before springboot upgrade this header is not causing any issues despite elasticsearch client being on 7.17.x and server on 7.9.x. Commented Feb 27, 2023 at 13:23

1 Answer 1

1

I checked the code of Spring Data Elasticsearch why and under which circumstances this header is sent in version 5.0.0:

  1. When using the old reactive client implementation (the new one uses the same transport function as the new ElasticsearchClient). As this old reactive client only was built with Elasticsearch 7 compatibility it now sets this header.
  2. When the new ElasticsearchClient is created (this was already possible in 4.4 with Elasticsearch 7.17 or a few versions earlier, although optional). When now building the transport for the new client, this header is set to the version of the used library. This transport is used for the new reactive client as well.

You are referencing a dependency of the RestHighLevelClient, but that code does not send this header, so you are probably reactive or using the new client. How is your client set up, which client class do you use?

The main problem however is that the version of Elasticsearch server you use is more than two years old (7.9.3 was released on October 22nd 2020) and does not understand this header. The last Spring Data Elasticsearch version using that Elasticsearch dependency was 4.1, 4.2 already was built against 7.12.0.

Sign up to request clarification or add additional context in comments.

2 Comments

I've added my configuration as an answer below. This is the only way I am setting my client. (Before spring boot upgrade this was not present, earlier it was just elasticsearch details in the properties/yml file)
@UdayPatil your configuration should better be added to your question. You can edit your question and add more context to it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.