es聚合统计查询

es聚合统计查询,第1张

es聚合统计查询
#基数统计
GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "customer_id_card": {
      "cardinality": {
        "field": "customer_id",
        "precision_threshold": 80
      }
    }
  }
}

#字段数量统计
GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "value_count_product_id": {
      "value_count": {
        "field": "products._id.keyword"
      }
    }
  }
}

GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "string_stats_costomer_full_name": {
      "string_stats": {
        "field": "string_stats_costomer_full_name.keyword"
      }
    }
  }
}

GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "sum_taxful_total_price": {
      "sum": {
        "script": {
          "source": """
          doc["taxful_total_price"].value*params.mulitfy;
          """,
          "params": {
            "mulitfy":10
          }
        }
      }
    },
    "stats_taxful_total_price":{
      "stats": {
        "field": "taxful_total_price_01",
        "missing": 0
      }
    }
  }
}

GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "term_":{
      "terms": {
        "field": "customer_id",
        "size": 100
      },
      "aggs": {
        "max_taxful_total_price": {
          "max": {
            "field": "taxful_total_price"
          }
        },
        "top_hits_detail":{
          "top_hits": {
            "size": 10,
            "_source": {
              "includes": ["costomer_full_name","products._id"]
            },
            "sort": [
              {
                "order_date": "desc"
              }
              ]
          }
        }
      }
    }
  }
}

GET kibana_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "top_metrics_total_quantity": {
      "top_metrics": {
        "metrics": {
          "field": "total_quantity"
        },
        "sort": {
          "total_quantity": "desc"
        },
        "size": 10
      }
    }
  }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5705327.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存