其他分享
首页 > 其他分享> > es聚合查询语句

es聚合查询语句

作者:互联网

POST activity_skc/_search
{
"query": {
"match_all": {}
},
"size": 0,
"aggs": {
"brandAgg": {
"terms": {
"field": "brand_id",
"size": 20,
"order": {
"sumSoldCount": "desc"
}
},
"aggs": {
"sumSoldCount": {
"sum": {
"field": "sold_num"
}
},
"minDiscountNum": {
"min": {
"script": {
"lang": "painless",
"source": " doc['ypc_price'].value/doc['market_price'].value * 10"
}
}
},
"maxDiscountNum": {
"max": {
"script": {
"lang": "expression",
"source": "doc['ypc_price']/doc['market_price']*10"
}
}
},
"tophits": {
"top_hits": {
"_source": [
"brand_id",
"brand_name",
"ypc_price",
"market_price"
],
"size": 1
}
}
}
}
}
}

标签:语句,聚合,doc,price,ypc,market,brand,es,size
来源: https://www.cnblogs.com/iceLi/p/15698352.html