# Null values in number field in Elasticsearch

**URL:** <https://discuss.elastic.co/t/null-values-in-number-field-in-elasticsearch/75270>\
**Category:** Elasticsearch\
**Created:** [February 16, 2017, 4:27am UTC](https://discuss.elastic.co/t/null-values-in-number-field-in-elasticsearch/75270 "2017-02-16T04:27:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Li](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@Leo\_Li](https://discuss.elastic.co/u/Leo_Li)\
**Post date:** [February 16, 2017, 4:27am UTC](https://discuss.elastic.co/t/null-values-in-number-field-in-elasticsearch/75270/1 "2017-02-16T04:27:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 16, 2017, 4:27am UTC](https://discuss.elastic.co/t/null-values-in-number-field-in-elasticsearch/75270/2 "2017-03-16T04:27:56Z")

</div>

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