From ddab9f26f32d804274f5b9a4c54f6ae50aa08682 Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Tue, 2 Mar 2021 15:21:51 -0700 Subject: [PATCH] Update KQL field autocompletion to suggest fields that match search (#92559) (#93302) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../providers/kql_query_suggestion/field.test.ts | 11 +++++++++++ .../providers/kql_query_suggestion/field.tsx | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.test.ts b/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.test.ts index bea695779fda6..afc55d13af9d9 100644 --- a/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.test.ts +++ b/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.test.ts @@ -78,6 +78,17 @@ describe('Kuery field suggestions', () => { expect(suggestions.find(({ text }) => text === 'machine.os ')).toBeDefined(); }); + test('should field names that match the search', async () => { + const prefix = 'machi'; + const suffix = 'ne.os'; + const suggestions = await getSuggestions( + querySuggestionsArgs, + mockKueryNode({ prefix, suffix }) + ); + + expect(suggestions.find(({ text }) => text === 'machine.os ')).toBeDefined(); + }); + test('should return field names that start with the query first', async () => { const prefix = 'e'; const suffix = ''; diff --git a/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.tsx b/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.tsx index ef0f27ee93bb7..ac6f7de888320 100644 --- a/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.tsx +++ b/x-pack/plugins/data_enhanced/public/autocomplete/providers/kql_query_suggestion/field.tsx @@ -58,8 +58,7 @@ export const setupGetFieldSuggestions: KqlQuerySuggestionProvider