WARNING: Version 2.3 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Object datatype
editObject datatype
editJSON documents are hierarchical in nature: the document may contain inner objects which, in turn, may contain inner objects themselves:
PUT my_index/my_type/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 |
|
Which in turn contains an inner object called |
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 { "mappings": { "my_type": { "properties": { "region": { "type": "string", "index": "not_analyzed" }, "manager": { "properties": { "age": { "type": "integer" }, "name": { "properties": { "first": { "type": "string" }, "last": { "type": "string" } } } } } } } } }
The mapping type is a type of object, and has a |
|
The |
|
The |
You are not required to set the field type
to object
explicitly, as this is the default value.
Parameters for object
fields
editThe following parameters are accepted by object
fields:
Whether or not new |
|
Whether the JSON value given for the object field should be
parsed and indexed ( |
|
Sets the default |
|
The fields within the object, which can be of any
datatype, including |
If you need to index arrays of objects instead of single objects, read Nested datatype first.