Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the StringifiedValues behavior #2238

Open
swallez opened this issue Aug 15, 2023 · 0 comments
Open

Introduce the StringifiedValues behavior #2238

swallez opened this issue Aug 15, 2023 · 0 comments

Comments

@swallez
Copy link
Member

swallez commented Aug 15, 2023

🚀 Feature Proposal

Introduce the StringifiedValues behavior. This behavior indicates that all primitive values of a class can be represented as strings in addition to their native type. This is for types where ES accepts both strings and native types and will return either a string or a native type (e.g. cat responses and settings). It generalizes the Stringified wrapper types to all fields of a class.

Motivation

In #2222 (comment) we've identified the need to express at the class level that for some classes all fields can be returned as strings (notably cat responses and all settings).

Using Stringified for all fields in these types is cumbersome and error-prone if we forget some, as seen in the above issue. So adding a class-level behavior that also follows inheritance rules will allow defining fields using their semantic value types and avoid omissions.

Notes

1 - This behavior should be added in 3 steps:

  • add the behavior type definition to the specification
  • create a team-wide issue to update code generators (for languages where it's relevant)
  • and then update the spec to use StringifiedValues

2 - Naming is hard. The name StringifiedValues has been chosen as it's consistent with the existing Stringified.

Example

IndexSettings is a typical example (see current source).

export class IndexSettings
  implements AdditionalProperties<string, UserDefinedValue>,
  StringifiedValues
{
  index?: IndexSettings
  mode?: string
  routing_path?: string | string[]
  soft_deletes?: SoftDeletes
  sort?: IndexSegmentSort
  /** @server_default 1 */
  number_of_shards?: integer
  /** @server_default 0 */
  number_of_replicas?: integer
  number_of_routing_shards?: integer
  /** @server_default false */
  check_on_startup?: IndexCheckOnStartup
  /** @server_default LZ4 */
  codec?: string
  /** @server_default 1 */
  routing_partition_size?: integer
  /** @server_default true */
  load_fixed_bitset_filters_eagerly?: boolean
  /** @server_default false */
  hidden?: boolean
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant