Elasticsearch 使用scroll时出现异常 Trying to create more than 500 scroll contexts will not be allowed-阿里云开发者社区

开发者社区> 云计算> 正文
登录阅读全文

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

简介: Trying to create more than 500 scroll contexts will not be allowed in the next

简述

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

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
云计算
使用钉钉扫一扫加入圈子
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

其他文章
最新文章
展开