How to insert data into ElasticSearch from a json file using Java Bulk API?

I have been looking for a definite answer but couldn't find one.
The java bulk api example given expects us to write individual docs into index/type/id.
How to use it to insert data directly from json file?

My json file is as follows:

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }

If you have a file then I'd recommend using the REST Client instead and POST the file content to _bulk endpoint.

I don't think you can do that with the Java high level client (REST or Transport).
Might be wrong though but AFK ATM.

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