概述
(1)sum
GET /lib4/items/_search
{
“size”:0,
“aggs”: {
“price_of_sum”: {
“sum”: {
“field”: “price”
}
}
}
}
(2)min
GET /lib4/items/_search
{
“size”: 0,
“aggs”: {
“price_of_min”: {
“min”: {
“field”: “price”
}
}
}
}
(3)max
GET /lib4/items/_search
{
“size”: 0,
“aggs”: {
“price_of_max”: {
“max”: {
“field”: “price”
}
}
}
}
(4)avg
GET /lib4/items/_search
{
“size”:0,
“aggs”: {
“price_of_avg”: {
“avg”: {
“field”: “price”
}
}
}
}
(5)cardinality:求基数
GET /lib4/items/_search
{
“size”:0,
“aggs”: {
“price_of_cardi”: {
“cardinality”: {
“field”: “price”
}
}
}
}
(6)terms:分组
GET /lib4/items/_search
{
“size”:0,
“aggs”: {
“price_group_by”: {
“terms”: {
“field”: “price”
}
}
}
}
对那些有唱歌兴趣的用户按年龄分组
GET /lib3/user/_search
{
“query”: {
“match”: {
“interests”: “changge”
}
},
“size”: 0,
“aggs”:{
“age_group_by”:{
“terms”: {
“field”: “age”,
“order”: {
“avg_of_age”: “desc”
}
},
“aggs”: {
“avg_of_age”: {
“avg”: {
“field”: “age”
}
}
}
}
}
}
最后
以上就是畅快乐曲为你收集整理的【5】ElasticSearch聚合查询的全部内容,希望文章能够帮你解决【5】ElasticSearch聚合查询所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复