ES Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed
查看日志切分:
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]
日志内容:
{ "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 }
//boolQueryBuilder.should(QueryBuilders.termQuery("test.status", new int[]{1,2})); 正确: 数组过滤方式 boolQueryBuilder.should(QueryBuilders.termsQuery("test.status", new int[]{1,2}));
//源代码:参数是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; }