Closed
Description
Elasticsearch Version
Elasticsearch 8.0.0 running from docker image
Installed Plugins
No response
Java Version
bundled
OS Version
Elasticsearch docker
Problem Description
When sending a bulk index request to Elasticsearch 8.0.0 with the compatibility headers set for a client version 7, the bulk response is missing the _type
property in the index answer. This causes the client failing to parse the response.
Unable to parse response body for Response{requestLine=POST /_bulk?timeout=1m HTTP/1.1, host=http://localhost:9200, response=HTTP/1.1 200 OK}] with root cause
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:208) ~[na:na]
at org.elasticsearch.action.DocWriteResponse.<init>(DocWriteResponse.java:116) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.index.IndexResponse.<init>(IndexResponse.java:43) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.index.IndexResponse.<init>(IndexResponse.java:28) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.index.IndexResponse$Builder.build(IndexResponse.java:96) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.index.IndexResponse$Builder.build(IndexResponse.java:93) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.bulk.BulkItemResponse.fromXContent(BulkItemResponse.java:148) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.action.bulk.BulkResponse.fromXContent(BulkResponse.java:177) ~[elasticsearch-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2011) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$8(RestHighLevelClient.java:1673) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1749) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1702) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1672) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
at org.elasticsearch.client.RestHighLevelClient.bulk(RestHighLevelClient.java:577) ~[elasticsearch-rest-high-level-client-7.15.2.jar:7.15.2]
Steps to Reproduce
send a bulk index request with the RestHighLevelClient
7.15.2 to the cluster
POST http://localhost:9200/_bulk?timeout=1m HTTP/1.1
Accept: application/vnd.elasticsearch+json;compatible-with=7
Content-Type: application/vnd.elasticsearch+json;compatible-with=7
Authorization: Basic *****
Content-Length: 121
Host: localhost:9200
Proxy-Connection: Keep-Alive
User-Agent: elasticsearch-java/7.15.2-SNAPSHOT (Java/17.0.2)
X-Elastic-Client-Meta: es=7.15.2-SNAPSHOT,jv=17,t=7.15.2-SNAPSHOT,hc=4.1.5
{"index":{"_index":"entities","_id":"1"}}
{"id":"1","text":"text-1"}
This will return
HTTP/1.1 200 OK
X-elastic-product: Elasticsearch
content-type: application/vnd.elasticsearch+json;compatible-with=7
content-length: 202
{"took":13,"errors":false,"items":[{"index":{"_index":"entities","_id":"1","_version":5,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":40,"_primary_term":3,"status":200}}]}
When sending the same request to Elasticsearch 7.17.0 the following body is returned>
{"took":456,"errors":false,"items":[{"index":{"_index":"entities","_type":"_doc","_id":"1","_version":2,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":10,"_primary_term":2,"status":200}}]}
Here the _type
field is returned which is missing in the response from 8.0.0 .
Btw, when not using bulk, but a normal index for a single document, then the _type
is returned, it 's misisng in the bulk response.
Logs (if relevant)
No response