2014-02-19 87 views
1

我的索引包含兩個元素:SUM聚合是否舍入每個值?

{ 
    "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

驗證您的映射,是pound字段的類型設置爲double?它看起來像是一個integer

+0

其實這是一個「長」。接得好! –