We wanted to create IndexRequest, DeleteRequest, UpdateRequest and BulkRequest in Elasticsearch version 8 using JAVA APIs. But I don't see any java documentation in elasticsearch v8 official website. Previously in elasticsearch version 7, we used below code in order to perform operations.
IndexRequest indexRequest = Requests.indexRequest(index).id(key).source(source);
BulkRequest bulkRequest = Requests.bulkRequest();
bulkRequest.add(indexRequest);
Also following Elasticsearch Java API Client [8.1] , but no luck.
Problem arises when we try to do Requests.
indexRequest(), this Request class is not available in version 8.
So, Is it possible to create similar request in ES version 8 also?
Update 1:-
My point here is that I need to keep a list of request operation which maybe arbitrary ( maybe 1st five are inserts, next 2 are update and next 2 are delete requests and at the end 1 insert operation ). And that list needed to be flushed via Bulk maintaining the type of request received. I am using BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();
But my issue is with bulk update. I am unable to find any update API for bulkrequest for elasticsearch version 8.
For Insert:-
bulkRequestBuilder.operations(op -> op.index(idx -> idx.index(index).id(key).document(source)));
For Delete:-
bulkRequestBuilder.operations(op -> op.delete(d -> d.index(index).id(key)));
And flushing the bulk operation:-
BulkResponse bulkResponse = client.bulk(bulkRequestBuilder.build());
I am looking for something similar to above mentioned insert and delete operation.
Like, bulkRequestBuilder.operations(op->op.update(u->u.index(index).id(key)....))