elasticsearch - Aggregation based on range and term - Stack Overflow

admin2025-04-18  3

Problem: I want to have a bucket with range aggregation on win probability. But instead of having Bucket of "WON" based on win probability, have it on Constants.REVENUE_STATUS is "WON" or "WON_PENDING".

Condition:

  1. PIPELINE = REVN_WIN_PROBABILITY (9, 31)
  2. UPSIDE = REVN_WIN_PROBABILITY (39, 51)
  3. FORECAST = REVN_WIN_PROBABILITY (59,101)
  4. WON = REVENUE_STATUS = "WON" or "WON_PENDING"

Existing Code:

AbstractAggregationBuilder getRevenueWinProbAggregationBuilder() {
    AbstractAggregationBuilder rangeAggBuilder = AggregationBuilders
            .range(FORECAST_STATUS_TYPE_AGGREGATION_NAME)
            .field(Constants.REVN_WIN_PROBABILITY)
            .addRange(ForecastType.PIPELINE.toString(), 9, 31)
            .addRange(ForecastType.UPSIDE.toString(), 39, 51)
            .addRange(ForecastType.FORECAST.toString(), 59, 101)
            .addRange(ForecastType.WON.toString(), 99, 101);
    return rangeAggBuilder;
}
转载请注明原文地址:http://anycun.com/QandA/1744965569a90134.html