Elasticsearch 使用scroll时出现异常 Trying to create more than 500 scroll contexts will not be allowed in th

news/2024/7/7 5:48:07 标签: elasticsearch, java

简述

Trying to create more than 500 scroll contexts will not be allowed in the next major version by default
 You can change the  [search.max_open_scroll_context] setting to use a greater default value or lower the number of scrolls that you need to run in parallel."

问题原因

Elasticsearch 使用scroll时,中设置的timeout时间内,累计生成的scroll_id数超过了最大限制

问题解决方式

  • 减小timeout设置
 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(queryBuilder);
            searchSourceBuilder.size(5000);
            SearchRequest searchRequest = new SearchRequest();
            searchRequest.source(searchSourceBuilder);
            TimeValue timeValue = new TimeValue(3000);
            searchRequest.scroll(timeValue);
            searchRequest.indices("");
  • 清理scroll
 ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
                clearScrollRequest.addScrollId(scrollId);// 也可以选择setScrollIds()将多个scrollId一起使用
                ClearScrollResponse clearScrollResponse = null;
                try {
                    clearScrollResponse = produceRestClient.clearScroll(clearScrollRequest, RequestOptions.DEFAULT);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                boolean succeeded = clearScrollResponse.isSucceeded();
                log.info("--------------->>>>{}-----", succeeded);

http://www.niftyadmin.cn/n/860872.html

相关文章

Springboot 自定义注解及接口多实现注入(策略模式)干掉ifelse

简述 Spring Boot 中提供完善的依赖注入机制,极其便利。本文分享接口多实现注入,与自定义注解的结合使用。 目标实现,根据自定义注解类型,选择接口实现。 本文实例属于典型的策略模式设计,减少复杂if else 方式&…

你还在使用迭代器删除集合数据,out了,Java 中函数removeIf 不香么

简述 Java 中 集合List,Map在for循环中时,直接删除是不允许的操作。会出现如下异常 java.util.ConcurrentModificationExceptionat java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)at java.util.HashMap$EntryIterator.next(HashMap.java:1479)at ja…

python 发送匿名邮件或无发件人

简述 python 发送邮件一般可以通过smtplib,如果发送时不设置发送人信息,会有什么效果呢 取消发件人信息 取消From 信息设置。 import smtplib from email.header import Header from email.mime.text import MIMEText from email.utils import parse…

Spring Boot 2.3.6 与 Spring kafka 集成 出错(ClassNotFoundException: org.springframework.kafka.core.Microm

简述 spring boot 的出现最主要的原因之一就是解决spring的依赖管理,减少各种依赖包的冲突,让开发者重点关注开发本身,减少环境的配置。 在Spring Boot 没有出现之前,SSH框架整合,最开始的问题就是版本冲突&#xff…

JavaScript let 与var 区别及var弊端

let,const来源 ES2015 引入了两个重要的 JavaScript 新关键词:let 和 const。 这两个关键字在 JavaScript 中提供了块作用域(Block Scope)变量(和常量)。 在 ES2015 之前,JavaScript 只有两种类型的作用…

HazelCast获取全部的IMap信息

获取全部Imap信息 Collection<DistributedObject> distributedObjects HazelCastUtil.getInstance().getDistributedObjects();int i 0;for (DistributedObject object : distributedObjects) {if (object instanceof IMap) {IMap map HazelCastUtil.getInstance().ge…

maven 配置阿里云仓库与公司私服

简述 maven公司私服与阿里云的配置。 <profiles><profile><id>maven-release</id><repositories><!-- 公司私服 --></repositories></profile><profile><id>maven-snapshot</id><repositories><!…

Es6 Use Destructuring Assignment to Pass an Object as a Function‘s Parameters

问题 Use destructuring assignment within the argument to the function half to send only max and min inside the function. 源 const stats {max: 56.78,standard_deviation: 4.34,median: 34.54,mode: 23.87,min: -0.75,average: 35.85 };// Only change code below t…