Mapping a field that contains hexadecimal number?

I have a document that looks like the following:

"_index": "bla",
"_type": "blu",
"_source": {
    "id": "0x090256c0"
}

The 'id' field is an integer in hexadecimal format. If I try to use the following mapping for it:

"mappings": {
 "blu" : {
  "properties": { 
    "id": { 
      "type": "integer"  
    }  
  }
}

I get the following error:

'error': {'reason': 'failed to parse [id]', 'type': 'mapper_parsing_exception', 'caused_by': {'reason': 'For input string: "0x090256c0"

Is there a way to make ES understand that this field contains a hexadecimal value and not a string?

You can do the conversion in logstash using something like this

ruby { code => "event.set('[someField]', event.get('[otherField]').to_i(16))" }

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