zoukankan      html  css  js  c++  java
  • 48.cartinality的基本用法

    主要知识点

    • cartinality的用法

       

    es去重用的是cartinality metric算法,对每个bucket中的指定的field进行去重,然后获取去重后的count,类似于count(distcint)

       

    cartinality的用法

       

    GET /tvs/sales/_search

    {

    "size": 0,

    "aggs": {"mouth": {

    "date_histogram": {"field": "sold_date","interval": "month"},

    "aggs": {"distict_color": {"cardinality": {"field": "brand"}}}

    }

    }

    }

       

    执行结果如下:

    "aggregations": {

    "mouth": {

    "buckets": [

    {

    "key_as_string": "2016-05-01T00:00:00.000Z",

    "key": 1462060800000,

    "doc_count": 1,

    "distict_color": {

    "value": 1

    }

    },

    {

    "key_as_string": "2016-06-01T00:00:00.000Z",

    "key": 1464739200000,

    "doc_count": 0,

    "distict_color": {

    "value": 0

    }

    },

  • 相关阅读:
    CF1442E. Black, White and Grey Tree
    CF1442D. Sum
    CF1444D. Rectangular Polyline
    arc107F
    外心与垂心关系
    CF1434E. A Convex Game
    CF1434D. Roads and Ramen
    arc106E
    arc106F
    CF704E. Iron Man
  • 原文地址:https://www.cnblogs.com/liuqianli/p/8535892.html
Copyright © 2011-2022 走看看