Preventing a Gauss decay function from returning 0 inside a function score query

The best strategy for you is to adjust scale and decay values. For example, to distinguish between 3 year and 5 year old, increase your scale to something bigger, e.g : "scale": "365d".

If it is not possible for you to adjust scale and decay, consider adding an arbitrary small value to your gaussian score, by introducing another function with "score_mode" : "sum". Something like this: Function_score, gaussian decay, handling multiple by zero