GET /my_index/blogpost/_search
{
"size" : 0,
"query": {
"bool": {
"must": [
{ "match": { "title": "relationships" }},
{ "match": { "user.name": "John" }}
]
}
},
"aggs": {
"users": {
"terms": {
"field": "user.name.raw",
"order": { "top_score": "desc" }
},
"aggs": {
"top_score": { "max": { "script": "_score" }},
"blogposts": { "top_hits": { "_source": "title", "size": 5 }}
}
}
}
}
elasticsearch 聚合那点事,用子聚合的结果进行排序。
最新推荐文章于 2024-04-11 08:30:00 发布