aggregate_count

The (str agg_name, str fieldname) returns the number documents that passed the relevant 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.

Example:

def score_function_recommendation( params, doc):
      score = 0.0 
      if match('genres'): 
         aggregate_count ("count_genres")      
         if match('languages'):
             aggregate_count ("count_genres_languages")
         score = 1
     return score

In the above example, the query results will include a key name 'aggregations', containing the following sub keys:

  • count_genres” - the number of candidates that passed the filter over genres.

  • "count_genres_languages" - the number of candidates that passed the filters over genres and languages.-

Last updated