Object field type
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
Generally available
JSON documents are hierarchical in nature: the document may contain inner objects which, in turn, may contain inner objects themselves:
PUT my-index-000001/_doc/1{ // "region": "US", "manager": { "age": 30, "name": { "first": "John", "last": "Smith" } } }
- The outer document is also a JSON object.
- It contains an inner object called
manager. - Which in turn contains an inner object called
name.
Internally, this document is indexed as a simple, flat list of key-value pairs, something like this:
{
"region": "US",
"manager.age": 30,
"manager.name.first": "John",
"manager.name.last": "Smith"
}
An explicit mapping for the above document could look like this:
PUT my-index-000001{ "mappings": { "properties": { "region": { "type": "keyword" }, "manager": { "properties": { "age": { "type": "integer" }, "name": { "properties": { "first": { "type": "text" }, "last": { "type": "text" } } } } } } } }
- Properties in the top-level mappings definition.
- The
managerfield is an innerobjectfield. - The
manager.namefield is an innerobjectfield within themanagerfield.
You are not required to set the field type to object explicitly, as this is the default value.
The following parameters are accepted by object fields:
dynamic- Whether or not new
propertiesshould be added dynamically to an existing object. Acceptstrue(default),runtime,falseandstrict. enabled- Whether the JSON value given for the object field should be parsed and indexed (
true, default) or completely ignored (false). subobjects- Whether the object can hold subobjects (
true, default) or not (false). If not, sub-fields with dots in their names will be treated as leaves instead, otherwise their field names would be expanded to their corresponding object structure. properties- The fields within the object, which can be of any data type, including
object. New properties may be added to an existing object.
In columnar index modes, object fields are always auto-flattened to leaf fields. The dynamic and enabled settings are preserved under prefix_properties rather than on the object mapper itself.
If you need to index arrays of objects instead of single objects, read Nested first.