Adding metadata to a mapping
Sometimes when we are working with our mapping, it is required to store some additional data to be used for display purpose, ORM facilities, permissions, or simply to track them in the mapping.
Elasticsearch allows storing every kind of JSON data we want in the mapping with the special field _meta
.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
How to do it...
The
_meta
mapping field can be populated with any data we want. Consider the following example:{ "order": { "_meta": { "attr1": ["value1", "value2"], "attr2": { "attr3": "value3" } } } }
How it works...
When Elasticsearch processes a new mapping and finds a _meta
field...