前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ES Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed

ES Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed

作者头像
oktokeep
发布2024-10-09 08:39:38
1230
发布2024-10-09 08:39:38
举报
文章被收录于专栏:第三方工具

查看日志切分: sed -n '/2022-03-21 01:50:11.785/,/2022-03-21 02:25:01.130/p' test-2022-03-21-1.log > 220321.txt 2022-03-21 01:55:01.153 [http-nio-1374-exec-9]org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]

日志内容:

代码语言:javascript
复制
{
	"error": {
		"root_cause": [{
			"type": "query_shard_exception",
			"reason": "failed to create query: {……
			"term\" : {\n                \"test.status\" : {\n                  \"value\" : \"]\",\n                  \"boost\" : 1.0\n                }……",
			"index_uuid": "tAihAg8iQhqt4xAaCh8JHA",
			"index": "order_idx"
		}],
		"type": "search_phase_execution_exception",
		"reason": "all shards failed",
		"phase": "query",
		"grouped": true,
		"failed_shards": [{
			"shard": 0,
			"index": "order_idx",
			"node": "DMRXw_qLQS-QsqFpckgVEw",
			"reason": {
				"type": "query_shard_exception",
				"reason": "failed to create query: {……
				"term\" : {\n                \"test.status\" : {\n                  \"value\" : \"]\",\n                  \"boost\" : 1.0\n                }……",
				"index_uuid": "tAihAg8iQhqt4xAaCh8JHA",
				"index": "order_idx",
				"caused_by": {
					"type": "number_format_exception",
					"reason": "For input string: \"]\""
				}
			}
		}]
	},
	"status": 400
}
代码语言:javascript
复制
//boolQueryBuilder.should(QueryBuilders.termQuery("test.status", new int[]{1,2}));
正确: 数组过滤方式
boolQueryBuilder.should(QueryBuilders.termsQuery("test.status", new int[]{1,2}));
代码语言:javascript
复制
//源代码:参数是Object
    //A Query that matches documents containing a term.
    public static TermQueryBuilder termQuery(String name, Object value) {
        return new TermQueryBuilder(name, value);
    }
    
    //A filter for a field based on several terms matching on any of them.
    public static TermsQueryBuilder termsQuery(String name, Object... values) {
        return new TermsQueryBuilder(name, values);
    }
    
    //TermQueryBuilder和TermsQueryBuilder是QueryBuilder子类
    public BoolQueryBuilder should(QueryBuilder queryBuilder) {
        if (queryBuilder == null) {
            throw new IllegalArgumentException("inner bool query clause cannot be null");
        }
        shouldClauses.add(queryBuilder);
        return this;
    }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-03-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档