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值,手動篩選值。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM