While uploading a 50 mb size huge JSON string in ElasticSearch using this method -
public static void postData(String json, String index, String type) {
RestClient client = RestClient.builder(new HttpHost(testHostPreProd, 443, "https")).build();
HttpEntity entity = new NStringEntity(json, ContentType.APPLICATION_JSON);
Response response = client.performRequest("POST", "/" + index + "/" + type + "/_bulk",
Collections.<String, String>emptyMap(), entity);
client.close();
}
The error is
Exception in thread "main" org.elasticsearch.client.ResponseException: POST https:someURL/indexHere/typeHere/_bulk: HTTP/1.1 413 Request Entity Too Large
{"Message":"Request size exceeded 10485760 bytes"}
Putting a counter in the code that works send 10k batches might work but I'm not sure how to do that.
Any suggestions on how to handle this issue?
For downloading a big amount of records you can use Scroll API:
https://www.elastic.co/guide/en/elasticsearch/reference/current/scroll-api.html
The mechanism is quite simple:
scroll_id
which is the marker to the last document that you have downloaded.Something like this: