使用sum聚合的返回值 - elasticsearch

时间:2016-03-17 10:41:39

标签: elasticsearch

我做了这个查询来总结我所有的双倍的“practiceValue”。

 {
    "size" : 0,
    "query" : {
        "bool" : {
            "must_not" : [
                {
                    "missing" : { "field" : "practiceObj.practiceValue" }
                }
             ],
             "must" : [
                {
                    "match" : { "entityObj.description" : "FIRST" }
                }
             ]
         }
    },
    "aggs" : {
        "total" : {  
            "sum" : { "script" : "(doc['practiceObj.practiceValue'].value)" 
        } 
    }
  }
}

我的查询返回以下内容:

{
    "took": 32,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 11477,
        "max_score": 0,
        "hits": []
    },
    "aggregations": {
        "total": {
            "value": 1593598.7499999984
        }
    }
}

如何使用“总”值来围绕它?

“value”等于1593598.7499999984,我想把它变成1593598.75

谢谢!

0 个答案:

没有答案