aggregate_percentile

The functionaggregate_percentile(str agg_name, str fieldname, list[float] percentiles) returns the percentiles of the field fieldname over all cabdidates that passed the filtering.

The aggregation result will be stored under the query results objects, under a key named "agg_name".

Input

  • agg_name(str) - Specifies the key that will be used to store the aggregation result under the query result.

  • fieldname(str) - The name of the field to aggregate. params[fieldname]must be of type keyword or list[keyword].

  • percentiles(list[float] or list[int]) - The list percentiles to calculate. Provided numbers must be integres or non fractional floats (i.e. 10.0).

Example:

def score_function_recommendation( params, doc):
      score = 0.0 
      if match('genres'): 
         aggregate_percentile("percentiles_revenue", 'revenue',[5,25,33,85])      
         score = 1.0
     return score

In the above example, the query results will include a key name 'aggregations', containing the sub key "percentiles_revenue", with the percentiles [5,25,33,85] of the field “revenue” over all candidates that passed the match('genres') condition.

Last updated