我正在尝试获取sum
字段price
和price_department
.
映射是:
'completed_order' => [
'properties' => [
'driver_id' => [
'type' => 'integer',
'index' => 'not_analyzed',
],
'order_id' => [
'type' => 'integer',
'index' => 'not_analyzed',
],
'price' => [
'type' => 'float',
'index' => 'not_analyzed',
],
'price_department' => [
'type' => 'float',
'index' => 'not_analyzed',
],
],
],
问题是总和price_department
是一个整数值。我还试图获取该领域的统计数据。结果是:
...'_source' =>
array (size=6)
'driver_id' => int 4469
'price' => float 5.99
'order_id' => int 2200676
'price_department' => float 5.99...
...'total_price' =>
array (size=1)
'value' => float 5.99
'department_price' =>
array (size=1)
'value' => float 5
'department_price_stats' =>
array (size=5)
'count' => int 1
'min' => float 5
'max' => float 5
'avg' => float 5
'sum' => float 5
aggs
是body
:_
'aggs' => [
'drivers' => [
'terms' => ['field' => 'driver_id','size' => 0,],
'aggs' => [
'total_price' => ['sum' => ['field' => 'price',],],
'department_price' => ['sum' => ['field' => 'price_department',],],
'department_price_stats' => ['stats' => ['field' => 'price_department',],],
],
],
],
如您所见,sum
ofprice
看起来正确,但sum
and stats
ofprice_department
被四舍五入并以整数形式返回。