[Solved] ES Query SIZE too large Error: ENTITY CONTENT IS TOO LONG [105539255] FOR THE CONFIGURED BUFFER LIMIT [104857600]

RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.setHttpAsyncResponseConsumerFactory(
          new HttpAsyncResponseConsumerFactory
            // Modified to 500MB 
            .HeapBufferedResponseConsumerFactory(300 * 1024 * 1024 ));
            request.source(SearchSourceBuilder.searchSource().query(boolQueryBuilder).size(10000));

SearchResponse response = null;
  try {
       response = yqClient.search(request, builder.build());
  } catch (IOException e) {
       e.printStackTrace();
  }

Can also be set by reflection

   // Set es query buffer size 
        RequestOptions requestOptions = RequestOptions.DEFAULT;
        Class<? extends RequestOptions> reqClass = requestOptions.getClass();
        Field reqField = reqClass.getDeclaredField("httpAsyncResponseConsumerFactory");
        reqField.setAccessible(true);
        //remove final
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(reqField, reqField.getModifiers() & ~Modifier.FINAL);
 
        // Set the default factory 
        reqField.set(requestOptions, new HttpAsyncResponseConsumerFactory() {
            @Override
            public HttpAsyncResponseConsumer<HttpResponse> createHttpAsyncResponseConsumer() {
                //500MB
                return new HeapBufferedAsyncResponseConsumer(5 * 100 * 1024 * 1024);
            }

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *