Below is the reslut of Elastic query with derivative aggregation
"utils_per_5m": {
"buckets": [
{
"key_as_string": "2020-04-15T21:10:00.000Z",
"doc_count": 1,
"utils": {
"value": 924
},
"key": 1586985000000
},
{
"key_as_string": "2020-04-15T21:15:00.000Z",
"doc_count": 1,
"utils": {
"value": 0
},
"utils_deriv": {
"value": -924
},
"key": 1586985300000
}
]
}
utils_per_5m.buckets array has two objects. Since using derivative, only the second object in the array will have util_deriv .
Usecase : filter utils_per_5m.buckets array (2 objects ) with the condition as
utils_per_5m.buckets.stream().filter(poll -> poll.utils_deriv.value != null && poll.utils_deriv.value < 0).collect(Collectors.toList())
while executing the script in painless, getting NPE, though null check in pace for poll.utils_deriv.value NULL prior to poll.utils_deriv.value < 0 .
But , poll.utils.value == 0 filter working , utils.value exists in both the utils_per_5m.buckets array objects.
utils_per_5m.buckets.stream().filter(poll -> poll.utils.value == 0).collect(Collectors.toList())
Can you clarify why poll.utils_deriv.value filter throwing NPE even after checking NULL , also second object in the array has matching data.