elasticsearch中的聚合函数
elasticsearch中的聚合函数求出平均年龄
计算出蜀国人物的平均年龄
GET test1/_search
{
"query": {
"match": {
"location.keyword": "蜀国"
}
},
"aggs": {
"age_avg": {
"avg": {
"field": "age"
}
}
}
}
数据结果的分组查询
数据结果的分组
GET test1/_search
{
"query": {
"match_all": {}
},
"aggs": {
"age_group": {
"range": {
"field": "age",
"ranges": [
{
"from": 0,
"to": 30
},
{
"from": 30,
"to": 50
}
]
}
}
}
}
局部更新
POST test2/_doc/1/_update
{
"doc":{
"name":"c22"
}
}