mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
3070f0bb7c
commit
5122ac32e5
6 changed files with 69 additions and 2 deletions
|
@ -51,3 +51,5 @@ export * from './fielddata_parameter';
|
|||
export * from './split_queries_on_whitespace_parameter';
|
||||
|
||||
export * from './locale_parameter';
|
||||
|
||||
export * from './max_shingle_size_parameter';
|
||||
|
|
|
@ -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 default is three shingle subfields. More subfields enables more specific queries, but increases index size.',
|
||||
})}
|
||||
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>
|
||||
);
|
|
@ -14,6 +14,7 @@ import {
|
|||
NormsParameter,
|
||||
SimilarityParameter,
|
||||
TermVectorParameter,
|
||||
MaxShingleSizeParameter,
|
||||
} from '../../field_parameters';
|
||||
import { BasicParametersSection, AdvancedParametersSection } from '../edit_field';
|
||||
|
||||
|
@ -24,7 +25,8 @@ interface Props {
|
|||
const getDefaultToggleValue = (param: string, field: FieldType) => {
|
||||
switch (param) {
|
||||
case 'similarity':
|
||||
case 'term_vector': {
|
||||
case 'term_vector':
|
||||
case 'max_shingle_size': {
|
||||
return field[param] !== undefined && field[param] !== getFieldConfig(param).defaultValue;
|
||||
}
|
||||
case 'analyzers': {
|
||||
|
@ -47,6 +49,10 @@ export const SearchAsYouType = React.memo(({ field }: Props) => {
|
|||
<AdvancedParametersSection>
|
||||
<AnalyzersParameter field={field} withSearchQuoteAnalyzer={true} />
|
||||
|
||||
<MaxShingleSizeParameter
|
||||
defaultToggleValue={getDefaultToggleValue('max_shingle_size', field.source)}
|
||||
/>
|
||||
|
||||
<NormsParameter />
|
||||
|
||||
<SimilarityParameter
|
||||
|
|
|
@ -894,4 +894,15 @@ export const PARAMETERS_DEFINITION = {
|
|||
},
|
||||
schema: t.string,
|
||||
},
|
||||
max_shingle_size: {
|
||||
fieldConfig: {
|
||||
type: FIELD_TYPES.SELECT,
|
||||
label: i18n.translate('xpack.idxMgmt.mappingsEditor.largestShingleSizeFieldLabel', {
|
||||
defaultMessage: 'Max shingle size',
|
||||
}),
|
||||
defaultValue: 3,
|
||||
formatters: [toInt],
|
||||
},
|
||||
schema: t.union([t.literal(2), t.literal(3), t.literal(4)]),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -256,6 +256,7 @@ describe('Properties validator', () => {
|
|||
enable_position_increments: [],
|
||||
depth_limit: true,
|
||||
dims: false,
|
||||
max_shingle_size: 'string_not_allowed',
|
||||
},
|
||||
// All the parameters in "goodField" have the correct format
|
||||
// and should still be there after the validation ran.
|
||||
|
@ -307,6 +308,7 @@ describe('Properties validator', () => {
|
|||
enable_position_increments: true,
|
||||
depth_limit: 20,
|
||||
dims: 'abc',
|
||||
max_shingle_size: 2,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -119,7 +119,8 @@ export type ParameterName =
|
|||
| 'points_only'
|
||||
| 'path'
|
||||
| 'dims'
|
||||
| 'depth_limit';
|
||||
| 'depth_limit'
|
||||
| 'max_shingle_size';
|
||||
|
||||
export interface Parameter {
|
||||
fieldConfig: FieldConfig;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue