How to map document field which can be a number OR string OR nested object?

I index exception messages and among other fields there a a couple ("Code",
"Status") which used to be numbers, so default dynamic mapping happily
mapped them as integers.

Then after some time it appeared that those fields are not necessarily
integers, they can be strings. When this happens default dynamic mapping
complains.So I have added the following mapping to force all suspicious
fields to be strings, rather than integers:

"match": "(?i)
"match_pattern": "regex",
"type" : "string",
"fields": {
"raw": { "type": "string", "index": "not_analyzed" }

But now the problem become worse again - in some cases those fields are not
even strings! Looking at incoming JSON - they are nested objects!

Well, I don't really care to parse them as nested objects. I only want
mapper not to blow up when it encounters one of those "can be anything"
fields. How to I configure that?

In the worst case - how can I completely ignore those fields to avoid
mapper failures?
But hopefully there is a way to store those fields somehow.

Any advice?

Thank you!

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit