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

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?

{
   "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
}
{
   "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.

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