Elasticsearch简单运算

求平均数

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "store_id": "9167c916-0bf2-4473-b2a0-ab445deeea48"
          }
        },
        {
          "range": {
            "buss_date": {
              "gte": "2018-5-28",
              "lte": "2018-6-24"
            }
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "from": 0,
  "size": 10,
  "sort": {
    "buss_date": {
      "order": "desc"
    }
  },
  "aggs": {
    "avg_dinner_open_tabs": {
      "avg": {
        "field": "dinner_open_tabs"
      }
    }
  },
  "_source": [
    "dinner_open_tabs",
    "buss_date"
  ]
}

猜你喜欢

转载自www.cnblogs.com/dimdusk/p/9256870.html