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

Refactor enum mappings parameter to allow for capital case types #92548

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Dec 23, 2022

We have a couple of existing enum mappings parameter that specify they enum type in lowercase letters. That is convenient to avoid having to convert back and forth lowercase and uppercase enum names, yet it does not follow coding conventions that constants should be in capital letters. More importantly, moving the on_script_error mapping parameter to a streamlined enum mapping parameter is not possible with lowercase type names because one of its values is continue which is a java reserved keyword.

With this commit we refactor the enum mappings parameter to provide their types in capital case, while users will keep on providing the corresponding values in lowercase. This only affects how the enum types are represented internally.

We have a couple of existing enum mappings parameters that specify they enum type in lowercase letters.
That is convenient to avoid having to convert enum names back and to uppercase or lowercase depending
on what's needed, yet it does not follow coding conventions in that constants should be in capital letters.
More importantly, moving the `on_script_error` mapping parameter to a streamlined enum mapping parameter is
not possible with lowercase type names because one of its values is `continue` which is a java reserved keyword.
It becomes a requirement that the actual value for an enum based mapping parameter can potentially differ from
the enum name. In general, the type name will be in capital letters, while the parameter value will be lowercase.

With this commit we refactor the enum mappings parameter to provide their types in capital case, while
users will keep on providing the corresponding values in lowercase. This only affects how the enum
types are represented internally. We can leverage toString for the enum types to do the lowercasing when needed.
@javanna javanna added :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring v8.7.0 labels Dec 23, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Dec 23, 2022
Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@javanna javanna merged commit c53becb into elastic:main Jan 11, 2023
@javanna javanna deleted the refactoring/mappings_enum__param_lowercase branch January 11, 2023 22:28
danielmitterdorfer pushed a commit to danielmitterdorfer/elasticsearch that referenced this pull request Jan 12, 2023
…stic#92548)

We have a couple of existing enum mappings parameters that specify they enum type in lowercase letters.
That is convenient to avoid having to convert enum names back and to uppercase or lowercase depending
on what's needed, yet it does not follow coding conventions in that constants should be in capital letters.
More importantly, moving the `on_script_error` mapping parameter to a streamlined enum mapping parameter is
not possible with lowercase type names because one of its values is `continue` which is a java reserved keyword.
It becomes a requirement that the actual value for an enum based mapping parameter can potentially differ from
the enum name. In general, the type name will be in capital letters, while the parameter value will be lowercase.

With this commit we refactor the enum mappings parameter to provide their types in capital case, while
users will keep on providing the corresponding values in lowercase. This only affects how the enum
types are represented internally. We can leverage toString for the enum types to do the lowercasing when needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants