-
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 missing max_shingle_size parameter to search_as_you_type #55161
Merged
sebelga
merged 4 commits into
elastic:master
from
sebelga:fix/add-missing-max_shingle_size-parameter
Jan 21, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b08e77a
Add "max_shingle_size" parameter so SearchAsYouType type
sebelga 81e6580
Add parameter schema + update tests
sebelga 25894c6
Merge branch 'master' into fix/add-missing-max_shingle_size-parameter
elasticmachine 54cc9ca
Update "max_shingle_size" text description
sebelga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...appings_editor/components/document_fields/field_parameters/max_shingle_size_parameter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { getFieldConfig } from '../../../lib'; | ||
import { EditFieldFormRow } from '../fields/edit_field'; | ||
import { UseField, Field } from '../../../shared_imports'; | ||
|
||
interface Props { | ||
defaultToggleValue: boolean; | ||
} | ||
|
||
export const MaxShingleSizeParameter = ({ defaultToggleValue }: Props) => ( | ||
<EditFieldFormRow | ||
title={i18n.translate('xpack.idxMgmt.mappingsEditor.maxShingleSizeFieldTitle', { | ||
defaultMessage: 'Set max shingle size', | ||
})} | ||
description={i18n.translate('xpack.idxMgmt.mappingsEditor.maxShingleSizeFieldDescription', { | ||
defaultMessage: | ||
'The largest shingle size to index the input with and create subfields for, creating one subfield for each shingle size between 2 and the max value.', | ||
})} | ||
defaultToggleValue={defaultToggleValue} | ||
> | ||
<UseField | ||
path="max_shingle_size" | ||
component={Field} | ||
config={getFieldConfig('max_shingle_size')} | ||
componentProps={{ | ||
euiFieldProps: { | ||
options: [ | ||
{ value: 2, text: '2' }, | ||
{ value: 3, text: '3' }, | ||
{ value: 4, text: '4' }, | ||
], | ||
}, | ||
}} | ||
/> | ||
</EditFieldFormRow> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -894,4 +894,14 @@ export const PARAMETERS_DEFINITION = { | |
}, | ||
schema: t.string, | ||
}, | ||
max_shingle_size: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we define a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch, yes indeed we should 👍 |
||
fieldConfig: { | ||
type: FIELD_TYPES.SELECT, | ||
label: i18n.translate('xpack.idxMgmt.mappingsEditor.largestShingleSizeFieldLabel', { | ||
defaultMessage: 'Max shingle size', | ||
}), | ||
defaultValue: 3, | ||
formatters: [toInt], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 had a tricky time parsing this. What do you think of this copy Gail and I came up 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.
I think it is great to strive for improving the UI help texts, but we should align them with our docs. So one is not "better" (easier to understand) than the other. This is the current text for the parameter
Also, I am not sure we should add the default (hardcoded) value in the translation. That would be one more place to look for if it ever changes. If we think it adds value, then better to write it in parenthesis (
Default: 3
) and read the value from the parameter definition constant.[EDIT] Just to be clear, I think it is great to improve the texts to explain a complex configuration parameter. But we should also make sure to port that effort to our docs if we've found an easier way to explain how a parameter behaves.
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 love the idea of updating our docs. What do you propose? Would you like to incorporate the change we suggested, and we'll create an issue to update the docs accordingly?
I hear you in terms of keeping the text maintainable. We have hardcoded values in our help text in various places, so this isn't the only place we'll have this problem. How about we hardcode it for now, and create an issue for universally implementing a more robust solution like the one you suggest?
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.
Yes let's do that 👍
Regarding the default value, I haven't looked in details where/when we started using default values in text description but I think we should try as much as possible to look how we did in previous places/forms and repeat the pattern (unless we decided that was a wrong idea).
This is how we did with follower indices and I think it was a great call
After we change the default: