Skip to content

Commit 5f7960e

Browse files
authored
Add a note about multi-valued doc values in the docs. (elastic#134107) (elastic#134186)
1 parent 3ecbed6 commit 5f7960e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/reference/elasticsearch/mapping-reference/doc-values.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ PUT my-index-000001
7373
1. The `status_code` field has `doc_values` enabled by default.
7474
2. The `session_id` has `doc_values` disabled, but can still be queried.
7575

76+
## Multi-valued doc values note
77+
78+
Elasticsearch supports storing multi-valued fields at index time. Multi-valued fields can be provided as a json array. However in the doc values format, the values aren't stored in the order as was provided at index time. Additionally, duplicates may be lost.
79+
This implementation detail of doc values is visible when features directly interact with doc values, which may be the case for example in ES|QL or aggregations in the search API. Note, that _source always returns arrays in the way that was provided at index time.
80+
81+
How the ordering differs depends on whether the array is mapped as keyword or a numeric field type. In case of the `keyword` field type, the multi-valued values for each document are ordered lexicographically and duplicates are lost. If retaining duplicates is important then the `counted_keyword` field type should be used.
82+
In case of numeric field types (e.g. `long`, `double`, `scaled_float`, etc.), the multi-valued values for each document are ordered in natural order and duplicates are retained.
7683

7784

7885

0 commit comments

Comments
 (0)