# aggregate\_min

The `aggregate_min (str agg_name, str fieldname)` returns the min of the field  "fieldname" over all documents that passed the relevant filtering.

The aggregation result will be stored under the query results objects, under a key named "`agg_name"`.&#x20;

### Input

* <mark style="color:purple;">agg\_name</mark>(str) - Specifies the key that will be used to store the aggregation result under the query result.&#x20;
* <mark style="color:purple;">fieldname</mark>(str) - The name of the field to aggregate. params\[<mark style="color:purple;">fieldname]</mark>must be of type float or int.

**Example:**

```python
def score_function_recommendation( params, doc):
      score1 = 0.0 
      if match('genres'): 
         aggregate_min ("min_budget_genres", "rating")      
         if match('languages'):
             aggregate_min ("min_budget", "rating")
         score1 += rarity_sum('genres')
     return score1 
```

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

* **"**<mark style="color:purple;">min\_budget\_genres</mark>**"** - the minimum of the field “**budget**” over all candidates that passed the filter over **genres**.
* **"**<mark style="color:purple;">min\_budget</mark>**"** - the minimum of the field “**budget**” over all candidates that passed the filters over **genres** and **languages**.
