Watcher Condition Returning "Null"

Hi everyone,

My condition is currently returning "null", however I know there are documents.
Can you please help me in figuring out why it's returning "null"?

// My watcher code thus far:

// Stimulated results output

Thank you in advanced :slight_smile:

the addressing scheme of your condition is wrong. Your condition is


the first part ctx.payload.aggregations.managedobjectref is correct, however before reaching the timerange field, you missed that there is a buckets array where each element contains a timerange field.

Thanks for replying @spinscale :slight_smile:

I realised that yesterday, however I am still getting "null".

//This is the output I am getting now.

// This is my console

this snippet

"ctx.payload.aggregations.managedobjectref.buckets.timerange.buckets.doc_count": {

does access the array, but does not take the element position into account like buckets.0. for the first element

So it should be

which takes the element position starting from 0?

please look at the data more closely. You will see that there are two buckets fields, and each of them is an array, so you need to use an index twice.

Yes, I just did that and got the answer

Thank you so much @spinscale
Really appreciate your help on this one :slight_smile:

Answer for future readers:

// Example:
Note: This is when there is only ONE array

Hi @spinscale,

Following on from this, what if I wanted to look at all the arrays, not just Array 0?


the you need use a script condition instead of the compare one, which allows you to walk through all the buckets.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.