From c22c15d89927a3545ef38e33dab8ea86b9c7f82f Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Wed, 29 Nov 2023 17:57:33 +0100 Subject: [PATCH 1/4] allowing in-here search with empty query --- .../src/components/Search/List.vue | 53 ++++++++++--------- .../web-app-search/src/portals/SearchBar.vue | 1 - 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index 55e2868f652..2f83904d1a6 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -397,31 +397,36 @@ export default defineComponent({ query['mediatype'] = mediaTypeParams.split('+').map((t) => `"${t}"`) updateFilter(mediaTypeFilter) } + // By definition (KQL spec) OR, AND or (GROUP) is implicit for simple cases where + // different or identical keys are part of the query. + // + // We list these operators for the following reasons nevertheless explicit: + // * request readability + // * code readability + // * complex cases readability + let searchTermArray = Object.keys(query).reduce((acc, prop) => { + const isArrayValue = Array.isArray(query[prop]) + + if (!isArrayValue) { + acc.push(`${prop}:${query[prop]}`) + } - return ( - // By definition (KQL spec) OR, AND or (GROUP) is implicit for simple cases where - // different or identical keys are part of the query. - // - // We list these operators for the following reasons nevertheless explicit: - // * request readability - // * code readability - // * complex cases readability - Object.keys(query) - .reduce((acc, prop) => { - const isArrayValue = Array.isArray(query[prop]) - - if (!isArrayValue) { - acc.push(`${prop}:${query[prop]}`) - } - - if (isArrayValue) { - acc.push(`${prop}:(${query[prop].join(' OR ')})`) - } - - return acc - }, []) - .join(' AND ') - ) + if (isArrayValue) { + acc.push(`${prop}:(${query[prop].join(' OR ')})`) + } + + return acc + }, []) + + // moving scope to the end of the query to prevent invalid query starting with AND + if (searchTermArray.length > 1) { + const scopeIndex = searchTermArray.findIndex((item) => item.includes('scope')) + if (scopeIndex > -1 && scopeIndex !== searchTermArray.length - 1) { + const scope = searchTermArray.splice(scopeIndex, 1) + searchTermArray = [...searchTermArray, ...scope] + } + } + return searchTermArray.join(' AND ') } const breadcrumbs = computed(() => { diff --git a/packages/web-app-search/src/portals/SearchBar.vue b/packages/web-app-search/src/portals/SearchBar.vue index f7659182471..0566f6d1742 100644 --- a/packages/web-app-search/src/portals/SearchBar.vue +++ b/packages/web-app-search/src/portals/SearchBar.vue @@ -220,7 +220,6 @@ export default defineComponent({ scope = unref(scopeQueryValue) } const useScope = - unref(term) && unref(currentFolderAvailable) && unref(locationFilterId) === SearchLocationFilterConstants.inHere router.push( From 8b5bc7d45853e94d296d46515a1b5e361ebd1fb8 Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Wed, 29 Nov 2023 18:03:16 +0100 Subject: [PATCH 2/4] updating filter condition for scope in search query --- packages/web-app-files/src/components/Search/List.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index 2f83904d1a6..c912cc8d52a 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -420,7 +420,7 @@ export default defineComponent({ // moving scope to the end of the query to prevent invalid query starting with AND if (searchTermArray.length > 1) { - const scopeIndex = searchTermArray.findIndex((item) => item.includes('scope')) + const scopeIndex = searchTermArray.findIndex((item) => item.includes('scope:')) if (scopeIndex > -1 && scopeIndex !== searchTermArray.length - 1) { const scope = searchTermArray.splice(scopeIndex, 1) searchTermArray = [...searchTermArray, ...scope] From 95cb135d0c006afa57b693eb58741deb41545526 Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Thu, 30 Nov 2023 18:42:12 +0100 Subject: [PATCH 3/4] using sort in scope search query --- .../src/components/Search/List.vue | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/packages/web-app-files/src/components/Search/List.vue b/packages/web-app-files/src/components/Search/List.vue index c912cc8d52a..ae766f84675 100644 --- a/packages/web-app-files/src/components/Search/List.vue +++ b/packages/web-app-files/src/components/Search/List.vue @@ -397,36 +397,31 @@ export default defineComponent({ query['mediatype'] = mediaTypeParams.split('+').map((t) => `"${t}"`) updateFilter(mediaTypeFilter) } - // By definition (KQL spec) OR, AND or (GROUP) is implicit for simple cases where - // different or identical keys are part of the query. - // - // We list these operators for the following reasons nevertheless explicit: - // * request readability - // * code readability - // * complex cases readability - let searchTermArray = Object.keys(query).reduce((acc, prop) => { - const isArrayValue = Array.isArray(query[prop]) - - if (!isArrayValue) { - acc.push(`${prop}:${query[prop]}`) - } - - if (isArrayValue) { - acc.push(`${prop}:(${query[prop].join(' OR ')})`) - } - - return acc - }, []) - - // moving scope to the end of the query to prevent invalid query starting with AND - if (searchTermArray.length > 1) { - const scopeIndex = searchTermArray.findIndex((item) => item.includes('scope:')) - if (scopeIndex > -1 && scopeIndex !== searchTermArray.length - 1) { - const scope = searchTermArray.splice(scopeIndex, 1) - searchTermArray = [...searchTermArray, ...scope] - } - } - return searchTermArray.join(' AND ') + return ( + // By definition (KQL spec) OR, AND or (GROUP) is implicit for simple cases where + // different or identical keys are part of the query. + // + // We list these operators for the following reasons nevertheless explicit: + // * request readability + // * code readability + // * complex cases readability + Object.keys(query) + .reduce((acc, prop) => { + const isArrayValue = Array.isArray(query[prop]) + + if (!isArrayValue) { + acc.push(`${prop}:${query[prop]}`) + } + + if (isArrayValue) { + acc.push(`${prop}:(${query[prop].join(' OR ')})`) + } + + return acc + }, []) + .sort((a, b) => a.startsWith('scope:') - b.startsWith('scope:')) + .join(' AND ') + ) } const breadcrumbs = computed(() => { From a4cc70abaef771864d02c21c55f2440e1a9efd71 Mon Sep 17 00:00:00 2001 From: Jacob Noah Date: Thu, 30 Nov 2023 21:18:44 +0100 Subject: [PATCH 4/4] in here search changelog --- changelog/unreleased/bugfix-in-here-search | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/bugfix-in-here-search diff --git a/changelog/unreleased/bugfix-in-here-search b/changelog/unreleased/bugfix-in-here-search new file mode 100644 index 00000000000..cef8f400ef6 --- /dev/null +++ b/changelog/unreleased/bugfix-in-here-search @@ -0,0 +1,6 @@ +Bugfix: Allow empty search query in "in-here" search + +Allowing empty search queries in the "in-here" search instead of fallback to search "everywhere". + +https://github.com/owncloud/web/pull/10092 +https://github.com/owncloud/web/issues/9970