码迷,mamicode.com
首页 > 其他好文 > 详细

[elk]elasticsearch dsl语句

时间:2018-12-28 16:04:05      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:key   ref   mooc   distinct   ast   tin   path   filter   nali   

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语句

标签:key   ref   mooc   distinct   ast   tin   path   filter   nali   

原文地址:https://www.cnblogs.com/iiiiiher/p/10190949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!