ES查询时size过大报错entity content is too long [105539255] for the configured buffer limit [104857600]
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder(); builder.setHttpAsyncResponseConsumerFactory( new HttpAsyncResponseConsumerFactory //修改为500MB .HeapBufferedResponseConsumerFactory(500 * 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(); }
也可以通过反射进行设置
//设置es查询buffer大小 RequestOptions requestOptions = RequestOptions.DEFAULT; Class<? extends RequestOptions> reqClass = requestOptions.getClass(); Field reqField = reqClass.getDeclaredField("httpAsyncResponseConsumerFactory"); reqField.setAccessible(true); //去除final Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(reqField, reqField.getModifiers() & ~Modifier.FINAL); //设置默认的工厂 reqField.set(requestOptions, new HttpAsyncResponseConsumerFactory() { @Override public HttpAsyncResponseConsumer<HttpResponse> createHttpAsyncResponseConsumer() { //500MB return new HeapBufferedAsyncResponseConsumer(5 * 100 * 1024 * 1024); }
原文链接:https://blog.csdn.net/qq_34412985/article/details/122122330
浙公网安备 33010602011771号