我需要计算索引为{“type”:long}的价格字段的总和。当我计算价格字段的总和时,它给我0而不是0.5。以下是我的json和聚合查询
{
"_index": "test",
"_type": "transaction",
"_id": "uh5Z-6GBSUez1cRVl5dXpQ",
"_score": 6.2806625,
"_source": {
"txn_id": "8982394",
"team_id": "4234234234",
"price": 0.5,
"tax": "0.00",
"gross_price": "0.50",
"payer_status": "unverified",
"currency_code": "USD",
"quantity": "1",
"payment_type": "paypal"
}
}
我的聚合查询是
{
"query": {
"match": {
"payment_type": "paypal"
}
},
"aggs": {
"daily_price_sum": {
"sum": {
"field": "price"
}
}
}
}
查询输出
"aggregations": {
"daily_price_sum": {
"value": 0 // Here it is showing sum as 0 instead of 0.5
}
请帮我解决这个问题。谢谢 }
答案 0 :(得分:1)
你提到价格是长型的。当提供0.5到一长的时间它会使数字四舍五入时,它不会以数学方式进行。因此存储的实际值不是0.5而是0.使它成为双倍。