Errors with High Level Rest Client After Upgrading to Elasticsearch 8.0.1

Hello,

After upgrading to Elasticsearch 8.0.1, I am having a variety of errors interfacing from my Java High Level Rest Client version 7.17.1 (originally tried with 7.15.2). The code now seems extremely sensitive to null pointer exceptions. There also seem to be new undocumented requirements. For example when creating an Index with an alias, I'm now forced to put alias.writeIndex(true) or I get an NPE.

However, I am currently stuck on Bulk Index Requests. I believe the data is being inserted correctly, but I am getting an NPE when Elasticsearch tries to parse the response, it is choking because the type parameter of the return is null. (DocWriteResponse line 116).

Here is a simplified extract of my code:

BulkRequest bulk = new BulkRequest();
	for(XContentBuilder data : bulkData) {
		IndexRequest req = new IndexRequest(indexName);
		req.source(data);
		req.type("_doc");
		bulk.add(req);
	}
BulkResponse resp = client.bulk(bulk, RequestOptions.DEFAULT);

client in the above code is a High Level Rest Client and all this code works fine on an ES 7.17.1 cluster. I did not originally have the type call above, but added it to see if that would fix the problem (it did not).

In my RestClientBuilder I have added (or tried to add) the Elasticsearch 7 compatibility headers like this:

Header[] defaultHeaders = {new BasicHeader("Accept", "application/vnd.elasticsearch+json; compatible-with=7"),
					new BasicHeader("Content-Type", "application/vnd.elasticsearch+json; compatible-with=7")};
			builder.setDefaultHeaders(defaultHeaders);
			RestClient llClient = builder.build();
			RestHighLevelClient client = new RestHighLevelClient(builder);

Does anyone have any tips or tricks to get this working with Elasticsearch 8.0.1?

Also I am running a single node on Windows 10 if that makes any difference.

Nevermind, I see this is being tracked here - bulk index response from 8.0.0 not compatible although headers are set · Issue #84173 · elastic/elasticsearch · GitHub

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.