Null values in number field in Elasticsearch

I have a number fields called carparks in Elasticsearch and I would like to create a new field using inline script, the inline script looks like this:
int total = 0;if(doc['carparks'].value == null) {total = 15;} else if(doc['carparks'].value == 0) {total = 1;} else {total = 2;} return total;

However it looks like all the null carparks values have been transformed to 0, so I cannot distinguish the condition between doc['carparks'].value == null and doc['carparks'].value == 0.

Can anyone please help this?

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