Object and nested types #
object
#
JSON documents are hierarchical in nature: the document may contain inner
objects which, in turn, may contain inner objects themselves. The object
type introduces inner objects.
{
"album": {
"artists": ["Bill Danoff", "Taffy Nivert", "John Denver"]
}
}
In the above JSON document, field “album” is of type object.
Parameters for object fields
#
- realtime — an
objectfield’srealtimeparameter would overwrite its sub-fields’realtimeparameter, even when they are explicitly set. - index — an
objectfield’sindexparameter would overwrite its sub-fields’indexparameter, even when they are explicitly set. - properties
- profile
- source / column / store
Support indexing multiple values #
Yes
nested
#
An object with
nested set to
true — also accepted directly as "type": "nested" (ES form; identical
schema). Sub-fields are indexed with ordinal tagging so that query clauses
evaluate per inner object instead of across objects — the basis of the
nested query.
PUT /my-collection/_schema
{
"diff": {
"reviews": {
"type": "nested",
"properties": {
"author": {"type": "keyword"},
"stars": {"type": "integer"}
}
}
}
}
The alias implies nested: true; opt out explicitly with
{"type": "nested", "nested": false} for a plain object. properties
may be empty — the dynamic schema fills them. Readback
(GET /<target>/_schema) presents stored object+nested pairs back as
"type": "nested", so the schema round-trips.
Negative example — nested on a non-object field is rejected with
400 mapper_parsing_exception (unknown parameter [nested]):
PUT /my-collection/_schema
{ "diff": { "title": { "type": "text", "nested": true } } } # 400
Parameters for nested fields
#
Support indexing multiple values #
Yes — an array of inner objects.