SUM聚合对每个值进行舍入?

时间:2014-02-19 14:00:42

标签: elasticsearch

我的索引包含两个元素:

{
  "pound" : 1.5
}

当ES通过SUM聚合将两个元素加在一起时,每个pound值都舍入为1,而不是保留1.5。为什么呢?

结果应该是3,而不是2

这是我的ES请求:

POST foo/bar/_search
{
   "aggs": {
      "sumPound": {
         "sum": {
            "field": "pound"
         }
      }
   }
}

回复:

{
   ...,
   "hits": {
      "total": 2,
      "max_score": 1,
      "hits": [
         {
            ...,
            "_source": {
               "pound": 1.5,
            }
         },
         {
            ...,
            "_source": {
               "pound": 1.5,
            }
         }
      ]
   },
   "aggregations": {
      "sumPound": {
         "value": 2          <-- 1.5 + 1.5 == 2 ???
      }
   }
}

1 个答案:

答案 0 :(得分:1)

验证您的映射,pound字段的类型是否设置为double?它看起来像integer