Is it possible to write a json/painless script that ignores some values?


(Génesis) #1

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.


(Alexander Reelsen) #2

you could filter out those documents using a range query, which is much faster than painless. Why do you specifically ask for painless, I guess I am missing something?

--Alex