Uday Patil
Uday Patil

Reputation: 75

Elasticsearch exception [type=exception, reason=Content-Type header [application/vnd.elasticsearch+json; compatible-with=7]

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

Version used after spring-boot upgrade

Upvotes: 1

Views: 4093

Answers (1)

Abacus
Abacus

Reputation: 19471

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.

Upvotes: 1

Related Questions