ES报错之-root_cause“:[{“type“:“query_shard_exception“,“reason“:“No mapping found for [] in order

博客内容讨论了在Elasticsearch中遇到的查询排序异常,原因是尝试对不存在的字段进行排序。解决方法是确保排序字段存在于文档中,避免空字段排序。通过对代码逻辑的修正,可以防止此类错误发生。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

{“error”:{“root_cause”:[{“type”:“query_shard_exception”,“reason”:“No mapping found for [] in order to sort on”

这个报错,说明排序字段""(没错我这里确实是空)在elastcsearch要排序的文档中不存在,然后我发现,因为我代码逻辑问题导致这里设置排序的字段为"",所以只要保证排序字段为当前文档中存在的字段即可。

curl -iX POST 'http://127.0.0.1:9200/getdeal_workform/_search?typed_keys=true' -d '{"_source":{"includes":["getdealid","fromtela","openx","wfid","fromname","wkfmno","workformno","fromtime","fmcontent","statedesc","wscode","dcntaname","dfmclaname","wskey","accsubject","stateflag"]},"from":0,"query":{"bool":{"must":[{"range":{"fromtime":{"to":"2025-07-08 00:00:00","format":"yyyy-MM-dd HH:mm:ss"}}},{"match":{"tablename":{"query":"t"}}}]}},"size":10,"sort":[{"getdealid":{"order":"desc"}}]}' # HTTP/1.1 400 Bad Request # X-elastic-product: Elasticsearch # content-type: application/vnd.elasticsearch+json;compatible-with=8 # content-length: 689 # # {"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: For input string: \"2025-07-08 00:00:00\"","index_uuid":"pyq8S-9xTYaXeUhxGT9Mvg","index":"getdeal_workform"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"getdeal_workform","node":"DRYANDKzTy6-GMiFw3XoDw","reason":{"type":"query_shard_exception","reason":"failed to create query: For input string: \"2025-07-08 00:00:00\"","index_uuid":"pyq8S-9xTYaXeUhxGT9Mvg","index":"getdeal_workform","caused_by":{"type":"number_format_exception","reason":"For input string: \"2025-07-08 00:00:00\""}}}]},"status":400} 2025-07-08 16:39:03.264 [http-nio-8180-exec-23] ERROR com.xhh.nphm.framework.web.exception.GlobalExceptionHandler - [notFount,64] - 访问的URL[/system/lookup/telGetAllEsList]发生异常[es/search] failed: [search_phase_execution_exception] all shards failed co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [search_phase_execution_exception] all shards failed
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值