-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Problem
The Fields
type is currently used wherever a collection of fields is expected. In most places, the server accepts the following values:
- missing /
null
[]
(no elements)["a"]
(single element)["a", "b", ...]
(multiple elements)
Unfortunately, there is a special case in all places where fields
is used for a stored_fields
property, a query parameter etc.. In these cases, special semantics are applied and the following values are accepted:
- missing/
null
(selects_id
and_type
[deprecated]) []
(selects_id
and_type
[deprecated])["a"]
(single element)["a", "b", ...]
(multiple elements)"_none_"
(string; deselects all fields)
While the exact semantics are usually not captured by the specification, this particular case needs to be modeled so that the generators can produce a specific serialization behavior. Elasticsearch does not accept the value _none_
as an element of an array (["_none_"]
) but requires it to be encoded as a string
. On the other hand, all regular places where fields
is used, explicitly do not accept single element as string
, but require the use of an array.
Proposal
Introduce a new alias type StoredFields = Fields
and use it for all stored_fields
properties. Generators can decide whether to just reduce the alias to Fields
or to implement special handling.
This mainly affects the statically typed language clients.
cc @swallez @Anaethelion @picandocodigo @l-trotta @stevejgordon