Sending BulkRequest in Java API Client Elasticsearch version 7.16.3

Hi everyone,
I have an java application which uses Elasticsearch and RestHighLevelClient.
The application simply reads csv files and creates a List of Maps java using Jackson CSV Mapper.
After that the Map is indexed in Elasticsearch by BulkRequest
BulkRequest bulkRequest = new BulkRequest();

for ( Map<String, Object> value : data ) {
	bulkRequest.add(new IndexRequest(index).source(value));
}
BulkResponse br = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT); 

I have not make any class corresponding to document in Java .
Now I am migrating my source code to new JavaAPI Client and using ElasticsearchClient in place of RestHighLevelClient.

Can, anyone guide me through how to create BulkRequest using ElasticsearchClient using Map only and not defining Document class because what i have seen mentioning Document type has been made mandatory.

I did a similar move recently. Not exactly the same but still.

So this code could help you hopefully:

@swallez helped me writing it :wink:

The client still needs some documentation to be written... A huge task for sure...

Also, this is a bit burried in the source code, but here is a useful Test class:

Thank you @dadoonet this is really helpful.

Finally got something to proceed with.

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