0
price
とprice_department
のsum
を取得しようとしています。Elasticsearch sumはfloatフィールドの丸められた整数値を返します
マッピングは:
'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
body
のaggs
は次のとおりです。
'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',],],
],
],
],
あなたが見ることができるように、price
のsum
が正しい見えますが、sum
とprice_department
のstats
は四捨五入して整数として返されます。
あなたのインデックスにある実際のマッピング、つまり 'curl -XGET localhost:9200/index'を実行すると、質問を更新してください – Val
どういうわけか、フィールド価格は倍で、price_departmentは長いです。なぜ彼らは変えることができましたか? – Justin
索引を作成して文書を索引付けした方法を知らずに伝えるのは難しいです。 – Val