Object field type

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

  1. PUT my-index-000001/_doc/1
  2. {
  3. "region": "US",
  4. "manager": {
  5. "age": 30,
  6. "name": {
  7. "first": "John",
  8. "last": "Smith"
  9. }
  10. }
  11. }

The outer document is also a JSON object.

It contains an inner object called manager.

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:

  1. {
  2. "region": "US",
  3. "manager.age": 30,
  4. "manager.name.first": "John",
  5. "manager.name.last": "Smith"
  6. }

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

  1. PUT my-index-000001
  2. {
  3. "mappings": {
  4. "properties": {
  5. "region": {
  6. "type": "keyword"
  7. },
  8. "manager": {
  9. "properties": {
  10. "age": { "type": "integer" },
  11. "name": {
  12. "properties": {
  13. "first": { "type": "text" },
  14. "last": { "type": "text" }
  15. }
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }

Properties in the top-level mappings definition.

The manager field is an inner object field.

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.

Parameters for object fields

The following parameters are accepted by object fields:

dynamic

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

enabled

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

properties

The fields within the object, which can be of any data type, including object. New properties may be added to an existing object.

If you need to index arrays of objects instead of single objects, read Nested first.