# Is there an elegant way of identifying mapping conflict exceptions programmatically?

**URL:** <https://discuss.elastic.co/t/is-there-an-elegant-way-of-identifying-mapping-conflict-exceptions-programmatically/254171>\
**Category:** Elasticsearch\
**Created:** [November 3, 2020, 3:17pm UTC](https://discuss.elastic.co/t/is-there-an-elegant-way-of-identifying-mapping-conflict-exceptions-programmatically/254171 "2020-11-03T15:17:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vangap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vangap/32/44927_2.png) [@vangap](https://discuss.elastic.co/u/vangap)\
**Post date:** [November 3, 2020, 3:17pm UTC](https://discuss.elastic.co/t/is-there-an-elegant-way-of-identifying-mapping-conflict-exceptions-programmatically/254171/1 "2020-11-03T15:17:39Z")

</div>

Below are some sample errors that ES returns for mapping conflicts which don't have any info that I can rely on programmatically.. I can't even seem to do regex parsing since different scenarios have different messages. How can reliably know that an error returned is because of mapping conflicts?

```auto
{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Can't merge a non object mapping [obj] with an object mapping [obj]"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "Can't merge a non object mapping [obj] with an object mapping [obj]"
   },
   "status": 400
}

```

```auto
{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "mapper [obj.email] of different type, current_type [text], merged_type [keyword]"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "mapper [obj.email] of different type, current_type [text], merged_type [keyword]"
   },
   "status": 400
}

```

Thanks in advance.

---

<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:** [December 1, 2020, 3:17pm UTC](https://discuss.elastic.co/t/is-there-an-elegant-way-of-identifying-mapping-conflict-exceptions-programmatically/254171/2 "2020-12-01T15:17:53Z")

</div>

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