-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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 histogram field type #76671
[Mappings editor] Add support for histogram field type #76671
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
@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 left a few comments to tidy things up but no blockers. Cheers.
} from '../../field_parameters'; | ||
import { BasicParametersSection, AdvancedParametersSection } from '../edit_field'; | ||
import { FormDataProvider } from '../../../../shared_imports'; | ||
|
||
const getDefaultToggleValue = (param: 'locale' | 'format' | 'boost', field: FieldType) => { | ||
const getDefaultToggleValue = (param: ParameterName, field: FieldType) => { | ||
if (param === 'meta') { |
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.
The default value for meta is ''
so L27 should be enough
import { AdvancedParametersSection } from '../edit_field'; | ||
|
||
export const BinaryType = () => { | ||
const getDefaultToggleValue = (param: ParameterName, field: FieldType) => { | ||
return field[param] !== undefined && field[param] !== ''; |
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.
Could we default to the more generic
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue;
like we do in the "range_type"?
@@ -24,8 +25,9 @@ const getDefaultToggleValue = (param: string, field: FieldType) => { | |||
case 'boost': { | |||
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue; | |||
} | |||
case 'meta': |
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 think "null_value" could have been left, and simply add "meta" on top of "boost"
import { EditFieldFormRow, AdvancedParametersSection } from '../edit_field'; | ||
|
||
const getDefaultToggleValue = (param: string, field: FieldType) => { | ||
switch (param) { | ||
case 'max_input_length': { | ||
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue; | ||
} | ||
case 'meta': { |
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 think we can simply add "meta" on top of "max_input_length"
case 'null_value': { | ||
return field.null_value !== undefined && field.null_value !== ''; | ||
return field[param] !== undefined && field[param] !== ''; |
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 here: I think "null_value" could have been left, and simply add "meta" on top of "boost"
case 'null_value': { | ||
return field.null_value !== undefined && field.null_value !== ''; | ||
return field[param] !== undefined && field[param] !== ''; |
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 here :) on top of "ignore_malformed"
@@ -29,6 +30,9 @@ const getDefaultToggleValue = (param: string, field: FieldType) => { | |||
case 'max_shingle_size': { | |||
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue; | |||
} | |||
case 'meta': { |
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 here: on top of "max_shingle_size"
@@ -46,8 +47,9 @@ const getDefaultToggleValue = (param: string, field: FieldType) => { | |||
case 'analyzers': { | |||
return field.search_analyzer !== undefined && field.search_analyzer !== field.analyzer; | |||
} | |||
case 'meta': |
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 here: on top of "boost"
case 'null_value': { | ||
return field.null_value !== undefined && field.null_value !== ''; | ||
return field[param] !== undefined && field[param] !== ''; |
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 here :)
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.
There is no more the need of try/catch
in serializer as now it is guaranteed to be a valid value (it has passed the validations defined, so here isJsonField
).
So it could simply by
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;
},
Ups! I went a bit fast on clicking the "Approve button" 😊
|
[EDIT] So I played a bit more with it and the steps to reproduce are slightly different:
Even without looking at the advanced configuration form (navigate to that tab), we get all of them in the request And saving it not allowed.
In your other PR with constant_keyword, no advanced config is added to the mappings but the same error is returned when adding some |
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.
Thanks for the review @sebelga! I believe I addressed your comments. Would you mind taking another look? Also, as mentioned in #76564, I believe the error you were hitting when saving I was not able to reproduce the issue you saw related to the advanced settings config. Can you retest and let me know if you're still able to reproduce? |
@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.
Thanks for making the changes! Tested locally and works as expected. You didn't add the validation for the meta values (string) but I guess it will get merged with the other PR.
[Edit] I could not reproduce the issue I mentioned with the advanced settings, which is good 👍
@elasticmachine merge upstream |
Thanks for the second review @sebelga!
The validation is there now that #76564 has been merged. I also updated the |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
History
To update your PR or re-run it, just comment with: |
Fixes #63937
I also created a common component for the
meta
parameter. While working on this PR, I found out from the ES team that this parameter is available to most field types so I added support where appropriate via df56ddc.Release note
The mappings editor in the Index Templates UI now supports configuring the histogram field type. Support for the
meta
parameter was also added to theboolean
,binary
,completion
,date
,flattened
,geo_point
,numeric
,range
,search_as_you_type
,token_count
andtext
field types.