搜索+聚合
    过滤+聚合

    1. GET /tvs/_search
    2. {
    3. "size": 0,
    4. "query": {
    5. "constant_score": {
    6. "filter": {
    7. "range": {
    8. "price": {
    9. "gte": 1200
    10. }
    11. }
    12. }
    13. }
    14. },
    15. "aggs": {
    16. "avg_price": {
    17. "avg": {
    18. "field": "price"
    19. }
    20. }
    21. }
    22. }
    {
      "took": 41,
      "timed_out": false,
      "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
      },
      "hits": {
        "total": 7,
        "max_score": 0,
        "hits": []
      },
      "aggregations": {
        "avg_price": {
          "value": 2885.714285714286
        }
      }
    }