OpenSearch/docs/reference/mapping
Adrien Grand 31158ab3d5
Add per-field metadata. (#50333)
This PR adds per-field metadata that can be set in the mappings and is later
returned by the field capabilities API. This metadata is completely opaque to
Elasticsearch but may be used by tools that index data in Elasticsearch to
communicate metadata about fields with tools that then search this data. A
typical example that has been requested in the past is the ability to attach
a unit to a numeric field.

In order to not bloat the cluster state, Elasticsearch requires that this
metadata be small:
 - keys can't be longer than 20 chars,
 - values can only be numbers or strings of no more than 50 chars - no inner
   arrays or objects,
 - the metadata can't have more than 5 keys in total.

Given that metadata is opaque to Elasticsearch, field capabilities don't try to
do anything smart when merging metadata about multiple indices, the union of
all field metadatas is returned.

Here is how the meta might look like in mappings:

```json
{
  "properties": {
    "latency": {
      "type": "long",
      "meta": {
        "unit": "ms"
      }
    }
  }
}
```

And then in the field capabilities response:

```json
{
  "latency": {
    "long": {
      "searchable": true,
      "aggreggatable": true,
      "meta": {
        "unit": [ "ms" ]
      }
    }
  }
}
```

When there are no conflicts, values are arrays of size 1, but when there are
conflicts, Elasticsearch includes all unique values in this array, without
giving ways to know which index has which metadata value:

```json
{
  "latency": {
    "long": {
      "searchable": true,
      "aggreggatable": true,
      "meta": {
        "unit": [ "ms", "ns" ]
      }
    }
  }
}
```

Closes #33267
2020-01-08 16:21:18 +01:00
..
dynamic [DOCS] Change // CONSOLE comments to [source,console] (#46441) (#46451) 2019-09-06 11:31:13 -04:00
fields [Docs] Fix syntax error leading to wrong doc ID (#48554) 2019-10-29 10:27:23 +01:00
params Add per-field metadata. (#50333) 2020-01-08 16:21:18 +01:00
types Add per-field metadata. (#50333) 2020-01-08 16:21:18 +01:00
dynamic-mapping.asciidoc [DOCS] Change // CONSOLE comments to [source,console] (#46441) (#46451) 2019-09-06 11:31:13 -04:00
fields.asciidoc Fix docs of the `_ignored` meta field. 2018-05-02 11:43:50 +02:00
params.asciidoc Add per-field metadata. (#50333) 2020-01-08 16:21:18 +01:00
removal_of_types.asciidoc [DOCS] Remove unneeded redirects (#50476) 2019-12-26 08:29:28 -05:00
types.asciidoc New Histogram field mapper that supports percentiles aggregations. (#48580) (#49683) 2019-11-28 15:06:26 +01:00