WARNING: Version 5.0 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.
properties
editproperties
editType mappings, object
fields and nested
fields
contain sub-fields, called properties
. These properties may be of any
datatype, including object
and nested
. Properties can
be added:
- explicitly by defining them when creating an index.
- explicitly by defining them when adding or updating a mapping type with the PUT mapping API.
- dynamically just by indexing documents containing new fields.
Below is an example of adding properties
to a mapping type, an object
field, and a nested
field:
PUT my_index { "mappings": { "my_type": { "properties": { "manager": { "properties": { "age": { "type": "integer" }, "name": { "type": "text" } } }, "employees": { "type": "nested", "properties": { "age": { "type": "integer" }, "name": { "type": "text" } } } } } } } PUT my_index/my_type/1 { "region": "US", "manager": { "name": "Alice White", "age": 30 }, "employees": [ { "name": "John Smith", "age": 34 }, { "name": "Peter Brown", "age": 26 } ] }
Properties under the |
|
Properties under the |
|
Properties under the |
|
An example document which corresponds to the above mapping. |
The properties
setting is allowed to have different settings for fields
of the same name in the same index. New properties can be added to existing
fields using the PUT mapping API.
Dot notation
editInner fields can be referred to in queries, aggregations, etc., using dot notation:
GET my_index/_search { "query": { "match": { "manager.name": "Alice White" } }, "aggs": { "Employees": { "nested": { "path": "employees" }, "aggs": { "Employee Ages": { "histogram": { "field": "employees.age", "interval": 5 } } } } } }
The full path to the inner field must be specified.