[[object]]
=== Object datatype

JSON documents are hierarchical in nature: the document may contain inner
objects which, in turn, may contain inner objects themselves:

[source,js]
--------------------------------------------------
PUT my_index/my_type/1
{ <1>
  "region": "US",
  "manager": { <2>
    "age":     30,
    "name": { <3>
      "first": "John",
      "last":  "Smith"
    }
  }
}
--------------------------------------------------
// CONSOLE
<1> The outer document is also a JSON object.
<2> It contains an inner object called `manager`.
<3> Which in turn contains an inner object called `name`.

Internally, this document is indexed as a simple, flat list of key-value
pairs, something like this:

[source,js]
--------------------------------------------------
{
  "region":             "US",
  "manager.age":        30,
  "manager.name.first": "John",
  "manager.name.last":  "Smith"
}
--------------------------------------------------

An explicit mapping for the above document could look like this:

[source,js]
--------------------------------------------------
PUT my_index
{
  "mappings": {
    "my_type": { <1>
      "properties": {
        "region": {
          "type": "keyword"
        },
        "manager": { <2>
          "properties": {
            "age":  { "type": "integer" },
            "name": { <3>
              "properties": {
                "first": { "type": "text" },
                "last":  { "type": "text" }
              }
            }
          }
        }
      }
    }
  }
}
--------------------------------------------------
// CONSOLE
<1> The mapping type is a type of object, and has a `properties` field.
<2> The `manager` field is an inner `object` field.
<3> The `manager.name` field is an inner `object` field within the `manager` field.

You are not required to set the field `type` to `object` explicitly, as this is the default value.

[[object-params]]
==== Parameters for `object` fields

The following parameters are accepted by `object` fields:

[horizontal]
<<dynamic,`dynamic`>>::

    Whether or not new `properties` should be added dynamically
    to an existing object.  Accepts `true` (default), `false`
    and `strict`.

<<enabled,`enabled`>>::

    Whether the JSON value given for the object field should be
    parsed and indexed (`true`, default) or completely ignored (`false`).

<<include-in-all,`include_in_all`>>::

    Sets the default `include_in_all` value for all the `properties` within
    the object. The object itself is not added to the `_all` field.

<<properties,`properties`>>::

    The fields within the object, which can be of any
    <<mapping-types,datatype>>, including `object`. New properties
    may be added to an existing object.

IMPORTANT: If you need to index arrays of objects instead of single objects,
read <<nested>> first.

