进阶-第41__深入聚合数据分析_过滤+聚合:统计价格大于1200的电视平均价格

 

搜索+聚合

过滤+聚合测试

GET /tvs/sales/_search

{

 "size": 0,

 "query": {

   "constant_score": {

     "filter": {

       "range": {

         "price": {

           "gte": 1200,

           "lte":1000000

         }

       }

     }

   }

 },

 "aggs": {

   "avg_price": {

     "avg": {

       "field": "price"

     }

   }

 }

}

 

过滤+聚合测试结果

{

  "took": 12,

  "timed_out": false,

  "_shards": {

    "total": 5,

    "successful": 5,

    "failed": 0

  },

  "hits": {

    "total": 7,

    "max_score": 0,

    "hits": []

  },

  "aggregations": {

    "avg_price": {

      "value": 2885.714285714286

    }

  }

}

 

 

猜你喜欢

转载自blog.csdn.net/qq_35524586/article/details/88565382