# When to use "Object" field datatype vs flat fieldnames

**URL:** <https://discuss.elastic.co/t/when-to-use-object-field-datatype-vs-flat-fieldnames/217687>\
**Category:** Elasticsearch\
**Tags:** ecs-elastic-common-schema\
**Created:** [February 3, 2020, 8:28pm UTC](https://discuss.elastic.co/t/when-to-use-object-field-datatype-vs-flat-fieldnames/217687 "2020-02-03T20:28:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Magnus\_Kessler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_kessler/32/42001_2.png) [@Magnus\_Kessler](https://discuss.elastic.co/u/Magnus_Kessler)\
**Post date:** [February 4, 2020, 1:03pm UTC](https://discuss.elastic.co/t/when-to-use-object-field-datatype-vs-flat-fieldnames/217687/2 "2020-02-04T13:03:57Z")

</div>

In this context, think of JSON objects as namespaces. Related information gets stored under a common root, which makes it easier for humans to identify which bits of the data belong together.

Functionally and performance-wise these 3 are equivalent:

- `"source_ip": "10.20.30.40"`
- `"source.ip": "10.20.30.40"`
- `"source": { "ip": "10.20.30.40"}`

The 3rd option groups the related fields in the `_source` of a document and makes it easier to read, IMO.

---

_[View the full topic](https://discuss.elastic.co/t/when-to-use-object-field-datatype-vs-flat-fieldnames/217687)._
