From 8b6caea44ef5fd4d08a3eff2b367d343a01ce7fd Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 2 Jul 2024 11:38:10 -0700 Subject: [PATCH] treat clause values as arrays --- .../public/search_syntax/parse_search_params.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/global_search_bar/public/search_syntax/parse_search_params.ts b/x-pack/plugins/global_search_bar/public/search_syntax/parse_search_params.ts index 8c32868c72d1a..b7fd924b66040 100644 --- a/x-pack/plugins/global_search_bar/public/search_syntax/parse_search_params.ts +++ b/x-pack/plugins/global_search_bar/public/search_syntax/parse_search_params.ts @@ -36,14 +36,16 @@ export const parseSearchParams = (term: string): ParsedSearchParams => { const unknownFilters = [...filterValues.entries()] .filter(([key]) => !knownFilters.includes(key)) - .reduce((unknowns, [key, value]) => { + .reduce((unknowns, [key, values]) => { // Unknown filters must be used as part of the search term. // Example: "remote:logs" is not a filter, it is a valid search term. - searchTerm = `${searchTerm} ${key}:${value}`; + if (Array.isArray(values) && values.length === 1) { + searchTerm = `${searchTerm} ${key}:${values[0]}`; + } return { ...unknowns, - [key]: value, + [key]: values, }; }, {} as Record);