我想在聚合汇总后,对聚合的bucket数据进行不响应,只是在响应时丢弃它


只想要 sumtotal 结果,不想要bookingIdGroup.buckets结果,但是它对我汇总sumtotal有作用。

GET /booking_order_list_v1/_search
{
  "from": 0,
  "size": 1,
  "aggs": {
    "bookingIdGroup": {
      "terms": {
        "field": "bookingId",
        "size": 10,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_key": "asc"
          }
        ]
      },
      "aggregations": {
        "bookingTeuTotal": {
          "sum": {
            "field": "bookingTeu"
          }
        },
        "supplementTeuTotal": {
          "sum": {
            "field": "supplementTeu"
          }
        },
        "actualTeu": {
          "bucket_script": {
            "buckets_path": {
              "supplementTeuTotal": "supplementTeuTotal",
              "bookingTeuTotal": "bookingTeuTotal"
            },
            "script": {
              "source": "params.bookingTeuTotal > params.supplementTeuTotal ? params.supplementTeuTotal : params.bookingTeuTotal",
              "lang": "painless"
            },
            "gap_policy": "skip"
          }
        }
      }
    },
    "sumtotal": {
      "sum_bucket": {
        "buckets_path": "bookingIdGroup.actualTeu"
      }
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.