elasticsearch中的分组聚合

GET /ecommerce/product/_search
{
  "size": 0,
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags",
        "order": {       //排序方式要写在aggs_type中,因为跳出aggs_type他就不知道是按照什么分类的了,更别说是排序
          "avg_price": "asc"
        }
      },
      "aggs": {
        "avg_price": {
          "avg": {
            "field": "price"
          }
        }
      }
    }
  }
}

你可能感兴趣的:(elaaticsearch)