Nested and Object Field Types
Learn how Elasticsearch handles JSON objects and arrays, why the default object type flattens data, and how the nested type preserves relationships inside arrays of objects.
Storing Structured Data
Real-world documents often contain nested structures: a blog post with comments, a product with variants, or an order with line items. Elasticsearch must decide how to index these JSON objects so they stay searchable.
This lesson covers the two main approaches: the default object type and the specialized nested type.
The Default object Type
By default, any JSON object inside a document is mapped as the object type. Elasticsearch flattens the inner fields into dotted paths.
A field author.name simply becomes a normal Lucene field. This is efficient and works perfectly for single objects.
PUT my_index/_doc/1
{
"author": { "first": "Jane", "last": "Doe" }
}All lessons in this course
- Customizing Field Mappings
- Dynamic vs. Explicit Mappings
- Index Templates and Aliases
- Nested and Object Field Types