Elasticsearch聚合查询的返回类型

时间:2019-08-13 08:07:00

标签: elasticsearch elasticsearch-aggregation

Elasticsearch聚合查询正在计算整数类型列的总和,返回浮点值。

我正在使用的索引的映射是:

{
  "index_name" : {
    "mappings" : {
      "doc" : {
        "properties" : {
         "spend" : {
        "type" : "integer"
       }
     }
   }
  }
 }
}

我写了以下查询:

GET /index_name/_search
{
  "size": 0,
  "query": {
    "bool": {
  "must": [
    {
      "term" : {
        "filter_column": "Filter_Value"
      }
    }
    ]
  }
},
"aggs" : {
  "sum_field" : {
    "sum" : {
    "field" : "spend"
    }
  }
 }
}

上述查询的结果是:

{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
  "total" : 5,
  "successful" : 5,
  "skipped" : 0,
  "failed" : 0
},
 "hits" : {
 "total" : 17985,
 "max_score" : 0.0,
 "hits" : [ ]
},
"aggregations" : {
"sum_field" : {
  "value" : 6020713.0
 }
}

}

我是否可以指定返回类型,使其返回整数值6020713而不是6020713.0

0 个答案:

没有答案