I'm trying to config my application to interaction with Elastcisearch server v7.7 using Java API Client v7.16.3. But when I try to index new document, I get the following error:
{"error":"Content-Type header [application/vnd.elasticsearch+json; compatible-with=7] is not supported","status":406}
As far as I understand, the reason is the compatibility Content-type
header which value contains compatible-with=7
. Elasticsearch v7.7 doesn't support this content-type (while Elasticsearch v7.15 works fine with it). Here is my configuration:
fun configElasticsearchRestClient(
host: String,
username: String,
password: String
): ElasticsearchClient {
val elasticsearchRestClient = RestClient.builder(HttpHost.create(host))
.build()
val transport: ElasticsearchTransport = RestClientTransport(
elasticsearchRestClient,
JacksonJsonpMapper()
)
return ElasticsearchClient(transport)
}
And here is indexing method:
fun index(document: SomeDocument) {
val indexRequest = IndexRequest.Builder<ObjectNode>()
.index("some-index")
.document(document)
.id(document.getId())
.version(document.getVersion())
.versionType(External)
.build()
elasticsearchClient.index(indexRequest)
}
Is it possible do disable compatibility headers for Java API Client? Or is there any another way to use Java API Client for Elasticsearch server v7.7?