zoukankan      html  css  js  c++  java
  • 46.颜色+品牌下钻分析时按最深层metric进行排序

    主要知识点:

    在做下钻分析时的排序

       

    需求,以颜色进行bucket,这里bucket里面的doc以其各品牌的平均价格排序,

       

    GET /tvs/sales/_search

    {

    "size": 0,

    "aggs": {"group_by_color": {

    "terms": {"field": "color"},

    "aggs": {"group_by_brand": {

    "terms": {"field": "brand","order": {"avg_price": "desc"}},

    "aggs": {"avg_price": {"avg": {"field": "price"}}}

    }

    }

    }

    }

    }

       

    这样红色里面有三星和长虹两个品牌,这两个品牌以平均价格排序。

    "aggregations": {

    "group_by_color": {

    "doc_count_error_upper_bound": 0,

    "sum_other_doc_count": 0,

    "buckets": [

    {

    "key": "红色",

    "doc_count": 4,

    "group_by_brand": {

    "doc_count_error_upper_bound": 0,

    "sum_other_doc_count": 0,

    "buckets": [

    {

    "key": "三星",

    "doc_count": 1,

    "avg_price": {

    "value": 8000

    }

    },

    {

    "key": "长虹",

    "doc_count": 3,

    "avg_price": {

    "value": 1666.6666666666667

    }

    }

    ]

    }

    },

  • 相关阅读:
    CSS实现返回网页顶部
    jQuery实现小火箭动态返回顶部代码
    Linux目录结构介绍
    Linux常用命令及技巧
    Linux文件系统
    Linux特性
    numpy中基础函数
    restful规范
    堆栈
    三次握手与四次挥手
  • 原文地址:https://www.cnblogs.com/liuqianli/p/8535871.html
Copyright © 2011-2022 走看看