Skip to content

Latest commit

 

History

History
34 lines (30 loc) · 975 Bytes

31_Nested_mapping.asciidoc

File metadata and controls

34 lines (30 loc) · 975 Bytes

Nested Object Mapping

Setting up a nested field is simple—​where you would normally specify type object, make it type nested instead:

PUT /my_index
{
  "mappings": {
    "blogpost": {
      "properties": {
        "comments": {
          "type": "nested", (1)
          "properties": {
            "name":    { "type": "string"  },
            "comment": { "type": "string"  },
            "age":     { "type": "short"   },
            "stars":   { "type": "short"   },
            "date":    { "type": "date"    }
          }
        }
      }
    }
  }
}
  1. A nested field accepts the same parameters as a field of type object.

That’s all that is required. Any comments objects would now be indexed as separate nested documents. See the {ref}/nested.html[nested type reference docs] for more.