原文地址: https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-mapping.html, 版权归 www.elastic.co 所有
WARNING: The 2.x versions of Elasticsearch have passed their EOL dates. If you are running a 2.x version, we strongly advise you to upgrade.
This documentation is no longer maintained and may be removed. For the latest information, see the current Elasticsearch documentation.
Nested Object Mappingedit
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.