Java Rest Client

Hi guys,

I have been trying unsuccessfully to do a bulk insert with the new Java rest client... Does anyone have a working example of a bulk insert using the rest client ?
I can do searches and index single documents without any issue but no bulk operations. I have tried with pretty much all the types of http entities but I am always getting a 400.
Here is a small example:
StringBuilder batch = new StringBuilder();
String bulkline = "{"index": {}}\n";
batch.append("{"kukta": "haha"}");
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200, "http")).build();
HttpEntity entity = new NStringEntity(batch.toString(), ContentType.APPLICATION_JSON);
Response indexResponse = restClient.performRequest(
Collections.<String, String>emptyMap(),

Thanks a lot,

May be this code can help you. Look at bulk method.

Thanks a lot!
I was missing a trailing newline in my bulk request

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