Elastic search null_value for integers is failing

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)

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

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