# Elastic search null\_value for integers is failing

**URL:** <https://discuss.elastic.co/t/elastic-search-null-value-for-integers-is-failing/113104>\
**Category:** Elasticsearch\
**Created:** [December 24, 2017, 3:59pm UTC](https://discuss.elastic.co/t/elastic-search-null-value-for-integers-is-failing/113104 "2017-12-24T15:59:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![putharekulu](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@putharekulu](https://discuss.elastic.co/u/putharekulu)\
**Post date:** [December 24, 2017, 3:59pm UTC](https://discuss.elastic.co/t/elastic-search-null-value-for-integers-is-failing/113104/1 "2017-12-24T15:59:41Z")

</div>

Ask Question  
up vote  
0  
down vote  
favorite  
i have the following in my mapping. The id can be null sometimes so i am using null\_value : 1. "Id" : { "type" : "integer", "store" : true, "doc\_values" : true, "null\_value" : 1, "index":"not\_analyzed" },

when i try to add documents to the index i am still getting parse error.How can i fix this

[2017-12-24 10:42:42,601][DEBUG][action.bulk][test-2017-12-24]  
[7] failed to execute bulk item (index) index {[test-2017-12-24][test]  
org.elasticsearch.index.mapper.MapperParsingException: failed to parse [Id]  
at

Caused by: java.lang.NumberFormatException: For input string: "null"  
at  
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)  
at java.lang.Integer.parseInt(Integer.java:580)  
at java.lang.Integer.parseInt(Integer.java:615)

---

<div class="post-metadata">

**Author:** ![luiz.santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz.santos/32/24664_2.png) [@luiz.santos](https://discuss.elastic.co/u/luiz.santos)\
**Post date:** [December 27, 2017, 4:16pm UTC](https://discuss.elastic.co/t/elastic-search-null-value-for-integers-is-failing/113104/2 "2017-12-27T16:16:07Z")

</div>

Hi @putharekulu,

You should use null without quotation marks:

```
PUT null_values
{
  "mappings": {
    "my_type": {
      "properties": {
        "status_code": {
          "type": "integer",
          "null_value": 1
        }
      }
    }
  }
}

POST null_values/my_type/1
{
  "field": "value",
  "status_code": null
}

GET null_values/_search
{
  "query": {
    "match": {
      "status_code": 1
    }
  }
} 

```

Hope it helps.

Cheers,  
LG

---

<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:** [January 24, 2018, 4:16pm UTC](https://discuss.elastic.co/t/elastic-search-null-value-for-integers-is-failing/113104/3 "2018-01-24T16:16:30Z")

</div>

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