# Parse json with mapper\_parsing\_exception

**URL:** <https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 2:14pm UTC](https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344 "2019-08-22T14:14:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thwint](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thwint/32/46431_2.png) [@thwint](https://discuss.elastic.co/u/thwint)\
**Post date:** [August 22, 2019, 2:14pm UTC](https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344/1 "2019-08-22T14:14:50Z")

</div>

Hello,  
We are indexing and parsing logfiles containing JSON requests (one per line). We have multiple, completely different request. Most of them can be indexed without any problems. But we have some requests which include a field with the same name once as concrete value and once as object.

Example (simplified request):

```
{
    "request": {
        "body": {
            "price": {
                "currency": "CHF",
                "value": 100.20
            }
        }
    }
}
```

or

```
{
    "request": {
        "body": {
            "price": 100
        }
    }
}
```

Depending which type of request was indexed first, one or the other cannot be indexed with the following error:  
"type"=\>"mapper\_parsing\_exception", "reason"=\>"object mapping for [response.body.price] tried to parse field [price] as object, but found a concrete value"

Is there a way to create an index/template to index the price field as object and once as concrete value?

Unfortunately we are not able to change all different types of requests to be indexed, but we are free to change the template.

Best regards,  
Tom

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 23, 2019, 7:09am UTC](https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344/2 "2019-08-23T07:09:40Z")

</div>

Hey,

each field can only have one type of mapping, either an object or a concrete field value. What you could do however is to change the structure of your JSON before indexing using an ingest processor. This way you could move the `request.body.price` field to `request.body.price.value` and then everything would work as expected.

For more information about processor and the ingest node, see [https://www.elastic.co/guide/en/elasticsearch/reference/7.3/ingest.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/ingest.html)

---

<div class="post-metadata">

**Author:** ![thwint](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thwint/32/46431_2.png) [@thwint](https://discuss.elastic.co/u/thwint)\
**Post date:** [August 23, 2019, 9:26am UTC](https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344/3 "2019-08-23T09:26:19Z")

</div>

Thanks for your reply. This seems to work.

---

<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:** [September 20, 2019, 9:26am UTC](https://discuss.elastic.co/t/parse-json-with-mapper-parsing-exception/196344/4 "2019-09-20T09:26:26Z")

</div>

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