# Best approach to fix mapping and reindex

**URL:** <https://discuss.elastic.co/t/best-approach-to-fix-mapping-and-reindex/93630>\
**Category:** Elasticsearch\
**Created:** [July 18, 2017, 5:11pm UTC](https://discuss.elastic.co/t/best-approach-to-fix-mapping-and-reindex/93630 "2017-07-18T17:11:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasSimoens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomassimoens/32/20187_2.png) [@ThomasSimoens](https://discuss.elastic.co/u/ThomasSimoens)\
**Post date:** [July 18, 2017, 5:11pm UTC](https://discuss.elastic.co/t/best-approach-to-fix-mapping-and-reindex/93630/1 "2017-07-18T17:11:18Z")

</div>

Hi, I'm pretty new to the ELK stack, but have spent some time in the docs, I'm truly amazed by all the features and existing (filter) plugins, but still somewhat unsure how to best put them to good use.

I'm looking for the best solution to fix attribute mapping: recently I've found that the 'dynamic mapping' caused some type mismatches:

- In some indeces the 'err' attribute was an object (e.g. `{id:"abc...", err: {code:"xyz..", message:"error message"} }`)
- In some indeces the 'err' attribute was just a string

Since this is a common problem, I've found that I need to need fix this by explict mapping and running an reindex, which i'm doing via `POST _reindex`.

To avoid the issue of 'inconsitent types' (resulting in `IllegalArgumentException`s or `mapper_parsing_exception`s), I've also found that the `script` attribute can be passed to the `_reindex` method.

To avoid the issue for new entries (so not during an actual `_reindex`, but avoiding the issue beforehand), I've found I need to fix the attribute mapping, and this can be done in a couple of ways by using different filter plugins or even the native 'field references' `[err]`. Although these native reference doen't seem to support data type checking (string, object/hash, number, ...) as far as I can tell.

Now since these two solutions will have similar behavior (checking the type and casting it to an object/map); I would like to know if it's possible to solve them in the same language; I found that the reindex supports `painless` and `groovy`, for the filters there is a `ruby` plugin, but I would like to avoid writing this conversion in a lot of different languages, but `ruby`isn't supported by `_reindex`.

So I would like know:

1. Am I missing an easier approach that doesn't require an extra language?
2. Is there a single language that is supported for both the `filter` plugins as well the `_reindex`?

---

<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:** [August 15, 2017, 5:23pm UTC](https://discuss.elastic.co/t/best-approach-to-fix-mapping-and-reindex/93630/2 "2017-08-15T17:23:25Z")

</div>

Closed on August 15, 2017, 5:23pm UTC

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