Java 1.8, Elasticsearch Low and High Level Rest Clients 7.0.0
I am trying the simple example from the docs found here: Bulk API
BulkRequest bulkRequest = new BulkRequest();
request.add(new IndexRequest("posts").id("1")
.source(XContentType.JSON,"field", "valueString"));
// not working
Map<String, Object> doc1 = new HashMap<>();
doc1.put("property", "value");
request.add(new IndexRequest("posts").id("1").source(doc1);
// this is easy to add as a single IndexRequest, but not working here
BulkResponse bulkResponse = this.getClient().bulk(request, RequestOptions.DEFAULT);
// this is the line throwing the error, straight from the docs
error:
{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"},"status":400}
at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:260)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:238)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1433)
... 6 more
so what type is missing? I have tried adding mappings, add opType("create") to the IndexRequest that is created inside the request.add()?
Yeah this is probably some simple oversight on my part but I have been wrestling this for a while guys and would appreciate some help.