# Issue with mapping in elasticsearch

**URL:** <https://discuss.elastic.co/t/issue-with-mapping-in-elasticsearch/336461>\
**Category:** Elasticsearch\
**Created:** [June 20, 2023, 10:12am UTC](https://discuss.elastic.co/t/issue-with-mapping-in-elasticsearch/336461 "2023-06-20T10:12:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanni](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Hanni](https://discuss.elastic.co/u/Hanni)\
**Post date:** [June 20, 2023, 10:12am UTC](https://discuss.elastic.co/t/issue-with-mapping-in-elasticsearch/336461/1 "2023-06-20T10:12:17Z")

</div>

Hi, I'm trying to index a field in elasticsearch with my index template. Except that my field can either be of type text (ex: No) or it can be of type float ( ex: 8.1). When I set the type to float in my mapping, I get errors parsing text values. I tried to define the type as "keyword". but when I want to create a data table visualization in kibana and I want to choose the range metric, I can't use my field because the range metric only works on numeric values. How can I proceed?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 20, 2023, 12:03pm UTC](https://discuss.elastic.co/t/issue-with-mapping-in-elasticsearch/336461/2 "2023-06-20T12:03:52Z")

</div>

You need to split the text content and the numbers into 2 fields.

It's better if you can do that before sending the data to Elasticsearch.  
Otherwise, you can create an ingest pipeline which converts the `foo` field to a `float` into a `foo_float` field. If you add `ignore_failure: true`, the field won't be created if not a number.

```auto
PUT _ingest/pipeline/to-float
{
  "processors" : [
    {
      "convert" : {
        "field" : "foo",
        "target_field" : "foo_float",
        "type": "float",
        "ignore_failure": true
      }
    }
  ]
}

```

---

<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:** [July 18, 2023, 12:03pm UTC](https://discuss.elastic.co/t/issue-with-mapping-in-elasticsearch/336461/3 "2023-07-18T12:03:54Z")

</div>

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