I thought of using a scripted field or just inputting a json script when visualizing data. For example, if I wanted to calculate the average of a field named 'time', but I don't want to take into account the docs with the 'time' field that equals a negative number.
If I had 10 docs, where 2 of them have 'time' = -1, it should only take into account 8 docs in order to calculate the average.