# How to handle inconsistent field types

**URL:** <https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064>\
**Category:** Elasticsearch\
**Created:** [September 9, 2022, 2:28pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064 "2022-09-09T14:28:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elastimatic](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@elastimatic](https://discuss.elastic.co/u/elastimatic)\
**Post date:** [September 9, 2022, 2:28pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064/1 "2022-09-09T14:28:48Z")

</div>

I am trying to index a JSON object (comes from Postgres) that has sometimes-inconsistent types that is tripping me up.

an example would be:

```auto
{
    "financials": {
        "amount": "100"
    }
},
{
    "financials": {
        "amount": "25.20"
    }
},

```

There are (unfortunately!) multiple fields like this. Is there a way I can set a sort of global flag to "treat it all as text"? It's tripping up on int vs. long, etc.

---

<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:** [September 9, 2022, 4:16pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064/2 "2022-09-09T16:16:34Z")

</div>

You can force the mapping to have this field as a text.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 9, 2022, 4:45pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064/3 "2022-09-09T16:45:25Z")

</div>

Or `keyword`

---

<div class="post-metadata">

**Author:** ![elastimatic](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@elastimatic](https://discuss.elastic.co/u/elastimatic)\
**Post date:** [September 16, 2022, 2:12pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064/4 "2022-09-16T14:12:51Z")

</div>

gotcha! thanks for the ideas here, I will try probably text first, since I see that still allows full text search, vs. keyword type.

---

<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 14, 2022, 2:13pm UTC](https://discuss.elastic.co/t/how-to-handle-inconsistent-field-types/314064/5 "2022-10-14T14:13:04Z")

</div>

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