# Mapping a field that contains hexadecimal number?

**URL:** <https://discuss.elastic.co/t/mapping-a-field-that-contains-hexadecimal-number/101212>\
**Category:** Elasticsearch\
**Created:** [September 20, 2017, 4:27pm UTC](https://discuss.elastic.co/t/mapping-a-field-that-contains-hexadecimal-number/101212 "2017-09-20T16:27:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avidane](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@avidane](https://discuss.elastic.co/u/avidane)\
**Post date:** [September 20, 2017, 4:27pm UTC](https://discuss.elastic.co/t/mapping-a-field-that-contains-hexadecimal-number/101212/1 "2017-09-20T16:27:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 20, 2017, 5:30pm UTC](https://discuss.elastic.co/t/mapping-a-field-that-contains-hexadecimal-number/101212/2 "2017-09-20T17:30:05Z")

</div>

You can do the conversion in logstash using something like this

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

---

<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:** [October 18, 2017, 5:30pm UTC](https://discuss.elastic.co/t/mapping-a-field-that-contains-hexadecimal-number/101212/3 "2017-10-18T17:30:08Z")

</div>

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