-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Mappings editor] Add support for constant_keyword field type #76564
[Mappings editor] Add support for constant_keyword field type #76564
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions. I didn't look closely at the other field types, so if they are inconsistent with existing UI text, I'd err on the side of consistency. (Though it looks like an editing pass of all of them might make sense at some point.)
...ents/mappings_editor/components/document_fields/fields/field_types/constant_keyword_type.tsx
Outdated
Show resolved
Hide resolved
...ents/mappings_editor/components/document_fields/fields/field_types/constant_keyword_type.tsx
Outdated
Show resolved
Hide resolved
...ents/mappings_editor/components/document_fields/fields/field_types/constant_keyword_type.tsx
Outdated
Show resolved
Hide resolved
...management/public/application/components/mappings_editor/constants/parameters_definition.tsx
Outdated
Show resolved
Hide resolved
...management/public/application/components/mappings_editor/constants/parameters_definition.tsx
Outdated
Show resolved
Hide resolved
<p> | ||
<FormattedMessage | ||
id="xpack.idxMgmt.mappingsEditor.dataType.constantKeywordLongDescription" | ||
defaultMessage="Constant keyword fields support the same queries and aggregations as {keyword} fields, but take advantage of the fact that all documents have the same value per index." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd lead with a definition of the field type.
defaultMessage="Constant keyword fields support the same queries and aggregations as {keyword} fields, but take advantage of the fact that all documents have the same value per index." | |
defaultMessage="A special type of keyword field for fields that contain the same keyword across all documents in the index. Supports the same queries and aggregations as {keyword} fields." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've typically started all the descriptions with the name of the field type, so I've changed this to:
Constant keyword fields are a special type of keyword field for fields that contain the same keyword across all documents in the index. Supports the same queries and aggregations as {keyword} fields."
…mappings_editor/components/document_fields/fields/field_types/constant_keyword_type.tsx Co-authored-by: debadair <[email protected]>
…mappings_editor/components/document_fields/fields/field_types/constant_keyword_type.tsx Co-authored-by: debadair <[email protected]>
…mappings_editor/constants/parameters_definition.tsx Co-authored-by: debadair <[email protected]>
Thanks @debadair for the copy review!
👍 The field type forms did go through copy review when they were initially added, but doesn't hurt to do a second pass at some point. |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @alisonelizabeth ! I tested locally and it works as expected. The issue I mentioned in #76671 around meta does not happen here.
But I would add an additional allowArray
in the isJsonField
validator (true
by default to not create breaking change) that would return an error if an array is provided and the option is set to false
.
return JSON.stringify(value, null, 2); | ||
}, | ||
serializer: (value: string) => { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here as in #76671. No need anymore of the try/catch
serializer: (value: string) => {
const parsed = JSON.parse(value);
// If an empty object was passed, strip out this value entirely.
if (!Object.keys(parsed).length) {
return undefined;
}
return parsed;
},
[EDIT] The isue with the It seems to occur when we use an index pattern that could also match other template, even with a totally unique field defined on the new template. And removing the meta fixes the ES error. I think that this should be investigated further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to investigate a bit further before approving as there is a very odd behavior. Maybe it is 100% on ES side, but I'd like to confirm this.
I'd like to investigate a bit further before approving as there is a very odd behavior. Maybe it is 100% on ES side, but I'd like to confirm this.
…ngs_editor/constant_keyword_field
@sebelga thanks for the review! I believe I addressed your feedback. Can you take another look when you get a chance? The
Do you think we should enforce these rules on the client? It is unfortunate that ES doesn't return a better error message. |
I will review it later today or tm morning.
I do think it'd be great to have a validator that makes sure that each value is a string. It is easy to add on our side and it could avoid a long debugging for the user to understand why his template is failing. Maybe the reason is better explained by ES deeply nested in the error. I opened #77165 to improve the error message surfaced in the UI. |
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes and adding the validation @alisonelizabeth ! Tested locally and works as expected 👍
…rok/new-patterns-component-use-array * 'master' of github.com:elastic/kibana: (140 commits) Add telemetry as an automatic privilege grant (elastic#77390) [Security Solutions][Cases] Cases Redesign (elastic#73247) Use Search API in TSVB (elastic#76274) [Mappings editor] Add support for constant_keyword field type (elastic#76564) [ML] Adds ML modules for Metrics UI Integration (elastic#76460) [Drilldowns] {{event.points}} in URL drilldown for VALUE_CLICK_TRIGGER (elastic#76771) Migrate status & stats APIs to KP + remove legacy status lib (elastic#76054) use App updater API instead of deprecated chrome.navLinks.update (elastic#77708) [CSM Dashboard] Remove points from line chart (elastic#77617) [APM] Trace timeline: Replace multi-fold function icons with new EuiIcon glyphs (elastic#77470) [Observability] Overview: Alerts section style improvements (elastic#77670) Bump the Node.js version used by Docker in CI (elastic#77714) Upgrade all minimist (sub)dependencies to version ^1.2.5 (elastic#60284) Remove unneeded forced package resolutions (elastic#77467) [ML] Add metrics app to check made for internal custom URLs (elastic#77627) Functional tests - add supertest for test_user (elastic#77584) [ML] Adding option to create AD jobs without starting the datafeed (elastic#77484) Bump node-fetch to 2.6.1 (elastic#77445) Bump sharkdown from v0.1.0 to v0.1.1 (elastic#77607) [APM]fixing y axis on transaction error rate to 100% (elastic#77609) ... # Conflicts: # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/manage_processor_form.container.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/manage_processor_form.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.scss # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/text_editor.scss # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/processors/grok.test.tsx
Fixes #69751
Release note
The mappings editor in the Index Templates UI now supports configuring the constant_keyword field type.