概述
世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问:max有什么特点?
答:
问:max如何使用?
答:
DELETE /max_test
PUT /max_test
{
"mappings": {
"properties": {
"num_1": {"type": "integer"},
"num_2": {"type": "integer"},
"histo": {"type": "histogram"}
}
}
}
POST /max_test/_bulk
{"index": {"_id": 1}}
{"num_1": 10, "num_2": 50, "histo": {"values": [1, 2, 3, 4], "counts": [3, 4, 6, 5]}}
{"index": {"_id": 2}}
{"num_1": 20, "num_2": 40, "histo": {"values": [1, 2, 3, 6], "counts": [3, 4, 6, 5]}}
{"index": {"_id": 3}}
{"num_1": 5, "num_2": 60, "histo": {"values": [1, 2, 3, 8], "counts": [3, 4, 6, 5]}}
{"index": {"_id": 4}}
{"num_1": 6, "num_2": 80, "histo": {"values": [1, 2, 3, 5], "counts": [3, 4, 6, 5]}}
GET /max_test/_search
{
"size": 0,
"aggs": {
"max_aggs": {
"max": {
"field": "num_1"
}
}
}
}
# 结果
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"max_aggs" : {
"value" : 20.0
}
}
}
GET /max_test/_search
{
"size": 0,
"aggs": {
"max_histo_aggs": {
"max": {
"field": "histo"
}
}
}
}
# 结果
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"max_histo_aggs" : {
"value" : 8.0
}
}
}
GET /max_test/_search
{
"size": 0,
"aggs": {
"max_num_script_aggs": {
"max": {
"field": "num_2",
"script": {
"lang": "painless",
"source": "_value * params.param",
"params": {
"param": 10
}
}
}
}
}
}
# 结果
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"max_num_script_aggs" : {
"value" : 800.0
}
}
}
最后
以上就是传统花生为你收集整理的es - elasticsearch - aggs - metrics - max的全部内容,希望文章能够帮你解决es - elasticsearch - aggs - metrics - max所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复