您應該使用統計方面(doc)
查詢應該是這樣的:
{
"query" : {
"match_all" : {}
},
"facets" : {
"statload_time" : {
"statistical" : {
"field" : "load_time"
}
},
"statexec_time" : {
"statistical" : {
"field" : "execution_time"
}
},
"statlog_time" : {
"statistical" : {
"field" : "log_time"
}
}
}
}
正如文檔所述:
統計數據包括計數,總數,平方和,平均值 (平均值),最小值,最大值,va riance和標準偏差
索引幾個文件後,查詢的響應是:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"statload_time" : {
"_type" : "statistical",
"count" : 2,
"total" : 7.0,
"min" : 2.0,
"max" : 5.0,
"mean" : 3.5,
"sum_of_squares" : 29.0,
"variance" : 2.25,
"std_deviation" : 1.5
},
"statexec_time" : {
"_type" : "statistical",
"count" : 2,
"total" : 12.0,
"min" : 5.0,
"max" : 7.0,
"mean" : 6.0,
"sum_of_squares" : 74.0,
"variance" : 1.0,
"std_deviation" : 1.0
},
"statlog_time" : {
"_type" : "statistical",
"count" : 2,
"total" : 16.0,
"min" : 7.0,
"max" : 9.0,
"mean" : 8.0,
"sum_of_squares" : 130.0,
"variance" : 1.0,
"std_deviation" : 1.0
}
}
}
我想這一點,但我得到的錯誤「unreognized令牌例外」,他說, : {「error」:「MapperParsingException [未解析];嵌套:JsonParseException [無法識別的令牌'load_time':期待('真','假'或'空') –
@CarmineGiangregorio你可以發佈你的映射? – moliware