[elk]elasticsearch dsl语句
Posted iiiiiher
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[elk]elasticsearch dsl语句相关的知识,希望对你有一定的参考价值。
sql转为dsl例子
# 每种型号车的颜色数 > 1的
SELECT model,COUNT(DISTINCT color) color_count FROM cars
GROUP BY model
HAVING color_count > 1
ORDER BY color_count desc
LIMIT 2;
GET cars/_search
{
"size": 0,
"aggs": {
"models": {
"terms": {
"field": "model.keyword"
},
"aggs": {
"color_count": {
"cardinality": {
"field": "color.keyword"
}
},
"color_count_filter": {
"bucket_selector": {
"buckets_path": {
"colorCount": "color_count"
},
"script": "params.colorCount>1"
}
},
"color_count_sort": {
"bucket_sort": {
"sort": {
"color_count": "desc"
},
"size": 2
}
}
}
}
}
}
23个有用的elasticsearch例子
https://cloud.tencent.com/developer/article/1367657
以上是关于[elk]elasticsearch dsl语句的主要内容,如果未能解决你的问题,请参考以下文章
2021年大数据ELK(十六):Elasticsearch SQL(职位查询案例)