diff --git a/packages/kbn-management/settings/application/hooks/use_fields.ts b/packages/kbn-management/settings/application/hooks/use_fields.ts index 829e368812512..f0dc538f54189 100644 --- a/packages/kbn-management/settings/application/hooks/use_fields.ts +++ b/packages/kbn-management/settings/application/hooks/use_fields.ts @@ -7,11 +7,13 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { Query } from '@elastic/eui'; +import { Ast, Query } from '@elastic/eui'; import { getFieldDefinitions } from '@kbn/management-settings-field-definition'; import { FieldDefinition } from '@kbn/management-settings-types'; import { UiSettingsScope } from '@kbn/core-ui-settings-common'; +import { Clause } from '@elastic/eui/src/components/search_bar/query/ast'; import { useServices } from '../services'; +import { CATEGORY_FIELD } from '../query_input'; import { useSettings } from './use_settings'; /** @@ -29,7 +31,19 @@ export const useFields = (scope: UiSettingsScope, query?: Query): FieldDefinitio isOverridden: (key) => isOverriddenSetting(key, scope), }); if (query) { - return Query.execute(query, fields); + const clauses: Clause[] = query.ast.clauses.map((clause) => + // If the clause value contains `:` and is not a category filter, add it as a term clause + // This allows searching for settings that include `:` in their names + clause.type === 'field' && clause.field !== CATEGORY_FIELD + ? { + type: 'term', + match: 'must', + value: `${clause.field}:${clause.value}`, + } + : clause + ); + + return Query.execute(new Query(Ast.create(clauses), undefined, query.text), fields); } return fields; };