From e51a23e607e20c1fd4c5a28f71ad2dab494229c3 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Tue, 25 Aug 2026 01:35:32 +0100 Subject: [PATCH] minor search filter fixes --- .../search/components/search-spotlight-filters.tsx | 5 +++-- .../src/features/search/components/search-spotlight.tsx | 6 ++++-- apps/server/src/core/search/search.service.ts | 7 ++++--- apps/server/src/database/types/db.d.ts | 1 - apps/server/src/ee | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/client/src/features/search/components/search-spotlight-filters.tsx b/apps/client/src/features/search/components/search-spotlight-filters.tsx index a99e598bb..96a7178ad 100644 --- a/apps/client/src/features/search/components/search-spotlight-filters.tsx +++ b/apps/client/src/features/search/components/search-spotlight-filters.tsx @@ -274,7 +274,8 @@ export function SearchSpotlightFilters({ )} - {orderedVisibleFilters.map((filterKey) => { + {!isAiMode && + orderedVisibleFilters.map((filterKey) => { if (filterKey === "creator") { return ( 0 && ( + {!isAiMode && addableFilters.length > 0 && ( 0 && !isAiLoading && !aiSearchResult ? t("No answer available") : "" - : query.length > 0 && !isFetching + : (query.length > 0 || isFilterBrowse) && !isFetching ? resultItems.length === 0 ? t("No results found") : t("{{count}} results found", { count: resultItems.length }) @@ -245,7 +245,9 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) { {resultItems.length > 0 && <>{resultItems}} - {(query.length > 0 || isFilterBrowse) && isFetching && ( + {(query.length > 0 || isFilterBrowse) && + isFetching && + resultItems.length === 0 && ( {t("Searching...")} diff --git a/apps/server/src/core/search/search.service.ts b/apps/server/src/core/search/search.service.ts index ae0a2c13c..3db29b274 100644 --- a/apps/server/src/core/search/search.service.ts +++ b/apps/server/src/core/search/search.service.ts @@ -42,6 +42,8 @@ export class SearchService { const searchQuery = tsquery(query + '*'); const titleOnly = searchParams.titleOnly === true; const titleQuery = query; + // escape LIKE wildcards; ranking keeps the raw query + const titleLikeQuery = query.replace(/[\\%_]/g, '\\$&'); const rankColumn = browseByFilters ? sql`0`.as('rank') @@ -84,7 +86,7 @@ export class SearchService { eb( sql`lower(f_unaccent(pages.title))`, 'like', - sql`lower(f_unaccent(${`%${titleQuery}%`}))`, + sql`lower(f_unaccent(${`%${titleLikeQuery}%`}))`, ), ), ) @@ -111,8 +113,7 @@ export class SearchService { queryResults = queryResults.select((eb) => this.pageRepo.withSpace(eb)); } - if (searchParams.spaceId) { - // search by spaceId + if (searchParams.spaceId && opts.userId) { queryResults = queryResults.where('spaceId', '=', searchParams.spaceId); } else if (opts.userId && !searchParams.spaceId) { // only search spaces the user is a member of diff --git a/apps/server/src/database/types/db.d.ts b/apps/server/src/database/types/db.d.ts index ac5b2c37c..4756c2636 100644 --- a/apps/server/src/database/types/db.d.ts +++ b/apps/server/src/database/types/db.d.ts @@ -312,7 +312,6 @@ export interface PageHistory { export interface Pages { content: Json | null; contributorIds: Generated; - labelIds: Generated; coverPhoto: string | null; createdAt: Generated; creatorId: string | null; diff --git a/apps/server/src/ee b/apps/server/src/ee index 0be4a7617..b51a46ef1 160000 --- a/apps/server/src/ee +++ b/apps/server/src/ee @@ -1 +1 @@ -Subproject commit 0be4a761754f673f7453f0a4e295168d181824c3 +Subproject commit b51a46ef104cb407a670462a36be79ef0da94f97