ElasticSearch错误“消息”:“请求大小超出10485760字节”

时间:2018-09-20 16:57:31

标签: java elasticsearch elasticsearch-bulk

使用此方法在ElasticSearch中上传大小为50 mb的巨大JSON字符串时-

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();
}

错误是

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"}

在可以发送10k批次的代码中放置一个计数器可能会起作用,但是我不确定如何做到这一点。

关于如何处理此问题的任何建议?

0 个答案:

没有答案