Skip to content

Commit 840cd11

Browse files
committed
Document that arrays are returned in an undefined order.
1 parent 594d631 commit 840cd11

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

docs/reference/search/search-fields.asciidoc

+9
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ the `_source`. Other mapping options are also respected, including
151151
<<ignore-above, `ignore_above`>>, <<ignore-malformed, `ignore_malformed`>> and
152152
<<null-value, `null_value`>>.
153153

154+
NOTE: The `fields` response always returns an array of values for each field,
155+
even when there is a single value in the `_source`. This is because {es} has
156+
no dedicated array type, and any field could contain multiple values. The
157+
`fields` parameter also does not guarantee that array values are returned in
158+
a specific order. See the mapping documentation on <<array, arrays>> for more
159+
background.
160+
161+
162+
154163
[discrete]
155164
[[docvalue-fields]]
156165
=== Doc value fields

server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ public void parse(ParseContext context) throws IOException {
284284
* In addition to pulling out the values, mappers can parse them into a standard form. This
285285
* method delegates parsing to {@link #parseSourceValue} for parsing. Most mappers will choose
286286
* to override {@link #parseSourceValue} -- for example numeric field mappers make sure to
287-
* parse the source value into a number of the right type.
287+
* parse the source value into a number of the right type. Some mappers may need more
288+
* flexibility and can override this entire method instead.
288289
*
289-
* Some mappers may need more flexibility and can override this entire method instead.
290+
* Note that for array values, the order in which values are returned is undefined and should
291+
* not be relied on.
290292
*
291293
* @param lookup a lookup structure over the document's source.
292294
* @param format an optional format string used when formatting values, for example a date format.

0 commit comments

Comments
 (0)