Skip to content

Latest commit

 

History

History
66 lines (56 loc) · 1.38 KB

object-field-type.md

File metadata and controls

66 lines (56 loc) · 1.38 KB

Object field type

PUT my-index-000001/_doc/1
{
  "region": "US",
  "manager": {
    "age":     30,
    "name": {
      "first": "John",
      "last":  "Smith"
    }
  }
}
  • 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:

{
  "region":             "US",
  "manager.age":        30,
  "manager.name.first": "John",
  "manager.name.last":  "Smith"
}

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

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "region": {
        "type": "keyword"
      },
      "manager": {
        "properties": {
          "age":  { "type": "integer" },
          "name": {
            "properties": {
              "first": { "type": "text" },
              "last":  { "type": "text" }
            }
          }
        }
      }
    }
  }
}
  • 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.

Source: https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html