首页 > 解决方案 > ElasticSearch 错误 ""Message":"请求大小超过 10485760 字节"

问题描述

使用此方法在 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 批次的代码中放置一个计数器可能有效,但我不知道该怎么做。

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

标签: javaelasticsearchelasticsearch-bulk

解决方案


推荐阅读