PLEASE NOTE:
We are working on updating this book for the latest version. Some content might be out of date.
We are working on updating this book for the latest version. Some content might be out of date.
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","properties": { "name": { "type": "string" }, "comment": { "type": "string" }, "age": { "type": "short" }, "stars": { "type": "short" }, "date": { "type": "date" } } } } } } }
That’s all that is required. Any comments
objects would now be indexed as
separate nested documents. See the
nested
type reference docs for more.