# Help on mapping for "catch-all" fields

**URL:** <https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182>\
**Category:** Elasticsearch\
**Created:** [March 11, 2016, 4:30pm UTC](https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182 "2016-03-11T16:30:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [March 11, 2016, 4:30pm UTC](https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182/1 "2016-03-11T16:30:26Z")

</div>

In a medium company, with 12 developers, I setup a super logger with logstash + elasticsearch where anyone can log anything.

Log documents are like this:

> {"date" : "....", "data" : {"myfield1":"hello", "myfield2": 3, "myfield3" : true ....}, "name" : "click"...}

Where data is the "catch-all" field, I mean myfield1 can be anything, posted by the developer. Problems appear if a dev A posts myfield1 as a string, and dev B posts it as a number, I got the famous:

> {"type"=\>"mapper\_parsing\_exception", "reason"=\>"object mapping for [event.data.tags] tried to parse field [tags] as object, but found a concrete value"}

What could be the best way to handle a such situation with logstash and elasticsearch ? I am thinking about 3 solutions:

- Force dev to respect a schema with proper naming
- Force dev to use a naming convention such as "myfield1\_{TYPE}" as type {TYPE}
- Transform field name according type to "myfield1\_{TYPE}"

Thanks,

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 11, 2016, 9:38pm UTC](https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182/2 "2016-03-11T21:38:42Z")

</div>

Mapping does not accept objects and primitives (string/number) at the same field.

In your example

```auto
{
  "event" : {
    "data" : {
      "tags" : "foobar"
    }
  }
}

```

and

```auto
{
  "event" : {
    "data" : {
      "tags" : {
          "foo" : "bar"
      }
    }
  }
}

```

Force your developers to send either objects or primitives to a field.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [March 12, 2016, 7:15am UTC](https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182/3 "2016-03-12T07:15:32Z")

</div>

Yep i understand, thanks you.

---

<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:** [July 5, 2017, 11:08pm UTC](https://discuss.elastic.co/t/help-on-mapping-for-catch-all-fields/44182/4 "2017-07-05T23:08:54Z")

</div>


