Using aggregation Json Input field to filter values

It wasn't working because I was using the wrong method.
This is the solution:

{ "script": "min(doc['field'].value, 100)", "lang" : "groovy" }