# Create root field for all fields

**URL:** <https://discuss.elastic.co/t/create-root-field-for-all-fields/245740>\
**Category:** Logstash\
**Created:** [August 20, 2020, 10:07am UTC](https://discuss.elastic.co/t/create-root-field-for-all-fields/245740 "2020-08-20T10:07:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [August 20, 2020, 1:45pm UTC](https://discuss.elastic.co/t/create-root-field-for-all-fields/245740/2 "2020-08-20T13:45:07Z")

</div>

You took [THIS](https://discuss.elastic.co/t/how-to-add-root-level-field-in-logstash-json-output/185010) script, but you changed the quotes. String interpolation only works with double quotes, so with the single quotes Ruby didn't replace `#{k}` with the field name, but put every field content into a field called `[message][#{k}]`. The first entry that was produced this way, had an object there, so the dynamic mapping of ES mapped the field as an object. Others had concrete values and therefore caused this error in ES because the data types didn't match. You need to keep the quotes the way they were in the original example.

---

_[View the full topic](https://discuss.elastic.co/t/create-root-field-for-all-fields/245740)._
