当前位置: 首页 > news >正文

Elasticsearch - No mapping found for [field_name] in order to sort on

chax根据关键字Action, MD5,模糊索引202*.log查询


curl -u user:'password' -H "Content-Type: application/json" 'http://127.1:9200/202*.log/_search?pretty' -XPOST -d '{"query": {"bool": {"should": [{"bool": {"must": [{"terms": {"Action": ["CREATE"]}},{"match_phrase": {"MD5": "9cb602258d4432668d887c3f3c86eca3"}}]}}]}},"sort":[{"Timestamp":{"order":"desc"}}],"size":3
}'

es返回消息,successful:15查询成功15条,failed:40查询失败40条记录。

{"took" : 99,"timed_out" : false,"_shards" : {"total" : 55,"successful" : 15,"skipped" : 0,"failed" : 40,"failures" : [{"shard" : 0,"index" : "2022.log","node" : "o5LJ-M2eRlOvpc1DTMRkEg","reason" : {"type" : "query_shard_exception","reason" : "No mapping found for [Timestamp] in order to sort on","index_uuid" : "Cg_KPEIDSXKkALQVrTUYoQ","index" : "2022.log"}},{"shard" : 0,"index" : "2023.log","node" : "o5LJ-M2eRlOvpc1DTMRkEg","reason" : {"type" : "query_shard_exception","reason" : "No mapping found for [Timestamp] in order to sort on","index_uuid" : "cl8DXfZeS0a2MBvuLFLdVg","index" : "2023.log"}}]},"hits" : {"total" : 0,"max_score" : null,"hits" : [ ]}
}

找一个查询失败日志分析

      {"shard" : 0,"index" : "2022.log","node" : "o5LJ-M2eRlOvpc1DTMRkEg","reason" : {"type" : "query_shard_exception","reason" : "No mapping found for [Timestamp] in order to sort on","index_uuid" : "Cg_KPEIDSXKkALQVrTUYoQ","index" : "2022.log"}} 

"type" : "query_shard_exception"查询分片异常,
"reason" : "No mapping found for [Timestamp] in order to sort on",没有mapping

可能的原因:在mapping中没有数据,也就是被排序的字段Timestamp在mapping中不存在,或者说一个index对应的mapping是空的。因此我们先找出索引对应的mapping信息。

查询索引相关的mapping信息: 

curl -u user:'password' -H "Content-Type: application/json" 'http://127.1:9200/202*.dat/_mapping?pretty'

结果:

{"2022.log" : {"mappings" : { }},"2023.log" : {"mappings" : { }},"2024.log" : {"mappings" : {"product_name" : {"properties" : {"Timestamp" : {"type" : "long"}}}}}
}

根据返回信息,2022.log, 2023.log对应的mapping都是空的,es没有对这两个索引排序。

因此需要用unmapped_type字段来忽略没有

curl -u user:'password' -H "Content-Type: application/json" 'http://127.1:9200/202*.log/_search?pretty' -XPOST -d '{"query": {"bool": {"should": [{"bool": {"must": [{"terms": {"Action": ["CREATE"]}},{"match_phrase": {"MD5": "9cb602258d4432668d887c3f3c86eca3"}}]}}]}},"sort":[{"Timestamp":{"order":"desc", "unmapped_type": "long"}}],"size":3
}'

参考: 

Elasticsearch - No mapping found for [field_name] in order to sort on

Sort search results | Elasticsearch Guide [7.13] | Elastic

http://www.lryc.cn/news/367561.html

相关文章:

  • Lua 元表(Metatable)深入解析
  • MySQL Show命令集
  • 倩女幽魂搬砖攻略:云手机自动托管搬砖刷本选哪家云手机?
  • php7.3安装phalcon扩展
  • IIoT(智能物联网)的现状、应用及安全
  • YOLOv8_obb的训练、验证、预测及导出[旋转目标检测实践篇]
  • C语言实战:贪吃蛇(万字详解)
  • 定时器更新界面,线程报错
  • 未来AI大模型的发展趋势
  • 【JavaScript函数详解】Day04
  • json和axion结合
  • v1.2.70-FastJson的AutoType机制研究
  • 老旧机子装linux——Xubuntu
  • 关于Redis中事务
  • 【数据分享】《中国文化文物与旅游统计年鉴》2022
  • 设计模式及其在软件开发中的应用
  • LeetCode72编辑距离
  • 竞拍商城系统源码后端PHP+前端UNIAPP
  • 千益畅行,共享旅游卡,灵活同行,畅游无忧的全方位解析
  • Web IDE 在线编辑器综合实践(Web IDE 技术探索 三)
  • Less is more VS 精一 [生活感悟]
  • 函数的概念及图像
  • Linux中Apache网站基于Http服务的访问限制(基于地址/用户)
  • 滚动条详解:跨平台iOS、Android、小程序滚动条隐藏及自定义样式综合指南
  • 06 Linux 设备驱动模型
  • 检测五个数是否一样的算法
  • java 原生http服务器 测试JS前端ajax访问实现跨域传post数据
  • 【机器学习】消息传递神经网络(MPNN)在分子预测领域的医学应用
  • Python Flask实现蓝图Blueprint配置和模块渲染
  • Vue10-事件修饰符