• elasticsearch 聚合函数 max double精度损失bug


    测试样例数据
    { "size" : 0, "query" : { "bool" : { "must" : { "bool" : { "must" : { "bool" : { "must" : { "match" : { "cankwxzwtm" : { "query" : "丹参", "type" : "phrase" } } } } } } } } }, "aggregations" : { "group_docid" : { "terms" : { "field" : "docid.raw", "size" : 1000 }, "aggregations" : { "maxid" : { "max" : { "field" : "longId" } } } } } }

      

    测试结果数据
    {
      "took": 3,
      "timed_out": false,
      "_shards": {
        "total": 3,
        "successful": 3,
        "failed": 0
      },
      "hits": {
        "total": 24,
        "max_score": 0,
        "hits": []
      },
      "aggregations": {
        "group_docid": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 0,
          "buckets": [
            {
              "key": "995922987708317699",
              "doc_count": 4,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317703",
              "doc_count": 2,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317708",
              "doc_count": 2,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987712512006",
              "doc_count": 2,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987712512012",
              "doc_count": 2,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987704123392",
              "doc_count": 1,
              "maxid": {
                "value": 995922987704123390
              }
            },
            {
              "key": "995922987708317700",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317701",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317704",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317705",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317706",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987708317709",
              "doc_count": 1,
              "maxid": {
                "value": 995922987708317700
              }
            },
            {
              "key": "995922987712512002",
              "doc_count": 1,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987712512007",
              "doc_count": 1,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987712512009",
              "doc_count": 1,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987712512010",
              "doc_count": 1,
              "maxid": {
                "value": 995922987712512000
              }
            },
            {
              "key": "995922987712512011",
              "doc_count": 1,
              "maxid": {
                "value": 995922987712512000
              }
            }
          ]
        }
      }
    }
    

      总结:maxid.value的值精度已经损失,没去官网深究原因,用terms替换max方法,得出所有id值,手动筛选值。

  • 相关阅读:
    webpack学习笔记--配置resolve
    常用 Git 命令清单
    彻底解决Webpack打包慢的问题
    vue-cli3安装遇到的问题,卸载不掉旧版本,导致更新不了
    在5分钟内搭建企业内部私有npm仓库
    package.json中你还不清楚的browser,module,main 字段优先级
    细说 peerDependencies
    对peerDependencies的理解
    [转载]罗技Usb Receiver在Win7 64位系统中驱动安装方法
    波峰波谷的判断
  • 原文地址:https://www.cnblogs.com/zzt-lovelinlin/p/9067917.html
Copyright © 2020-2023  润新知