Simple Scripted Field Error? (Kibana 4.1)

I am creating a scripted field 'popular' as the division of two Integer fields as below:

if (doc['age'].value) > 0
doc['popular'].value = doc['o.nbd'].value / doc['age'].value;
doc['popular'].value = -1;

However, after i submitted, Kibana does not load the index anymore. "There are errors in your input". After i delete the script field, it can load back again alright.

I am wondering if I have any errors in my script above?

Hi Allie,

Try an expression like this;

(doc['age'].value) > 0 ? doc['o.nbd'].value / doc['age'].value : -1

Please let me know if this works.