# Object mapping errors

**URL:** <https://discuss.elastic.co/t/object-mapping-errors/290032>\
**Category:** Logstash\
**Created:** [November 24, 2021, 9:25am UTC](https://discuss.elastic.co/t/object-mapping-errors/290032 "2021-11-24T09:25:19Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [November 25, 2021, 3:30am UTC](https://discuss.elastic.co/t/object-mapping-errors/290032/4 "2021-11-25T03:30:16Z")

</div>

You might (or might not) find [this](https://discuss.elastic.co/t/getting-illegal-state-exception-error-while-pushing-logs-to-elasticsearch/290029/2) post useful, which talks a little more about these mapping issues.

For renaming fields I would lean toward using mutate rather than ruby. For deciding whether you need to do the mutate ruby would work

```
ruby {
    code => '
        if event.get("file").is_a? String
            event.set("[@metadata][fileIsString]", true)
        end
    '
}
if [@metadata][fileIsString] {
    mutate { ... }
}

```

Note the single quotes around the code block of the ruby filter, so that you have the option to use string interpolation when needed.

---

_[View the full topic](https://discuss.elastic.co/t/object-mapping-errors/290032)._
