Bulk Insert to elastic search using java?

Hi,
I would like to insert a json array of data to elastic search . Each element in array represents different documents under a type . How can I achieve this using Java without any ES clients . ? Please suggest a solution.

You need to:

  • spilt the array into individual documents

For each doc:

  • create a header line for each doc
  • append each doc

At some point:

  • create an http call to the bulk API and pass what you built so far as the body

And continue until you don't have any remaining document

Hi dadoonet,
Thanks for your sudden replay . But actually i didn't get 'create a header line for each doc
' . I have checked through some documents . But didn't get a proper answer . Can u please suggest example code ? My document structure is like the following[{"index":{"_index":"test_index","_type":"test"}} {"number":1} {"index":{"_index":"test_index","_type":"test"}} {"number":1} {"index":{"_index":"test_index","_type":"test"}} {"number":1} {"index":{"_index":"test_index","_type":"test"}} {"number":1}] .

Bulk requests need to strictly follow the format shown in the examples in the documentation.

1 Like

Thanks You All. I have achieved it. :slight_smile:

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