minor search filter fixes

This commit is contained in:
Philipinho
2026-08-25 01:35:32 +01:00
parent d83ba56180
commit e51a23e607
5 changed files with 12 additions and 9 deletions
@@ -274,7 +274,8 @@ export function SearchSpotlightFilters({
</Button> </Button>
)} )}
{orderedVisibleFilters.map((filterKey) => { {!isAiMode &&
orderedVisibleFilters.map((filterKey) => {
if (filterKey === "creator") { if (filterKey === "creator") {
return ( return (
<CreatorFilterMenu <CreatorFilterMenu
@@ -340,7 +341,7 @@ export function SearchSpotlightFilters({
return null; return null;
})} })}
{addableFilters.length > 0 && ( {!isAiMode && addableFilters.length > 0 && (
<Menu <Menu
shadow="md" shadow="md"
width={200} width={200}
@@ -205,7 +205,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
? query.length > 0 && !isAiLoading && !aiSearchResult ? query.length > 0 && !isAiLoading && !aiSearchResult
? t("No answer available") ? t("No answer available")
: "" : ""
: query.length > 0 && !isFetching : (query.length > 0 || isFilterBrowse) && !isFetching
? resultItems.length === 0 ? resultItems.length === 0
? t("No results found") ? t("No results found")
: t("{{count}} results found", { count: resultItems.length }) : t("{{count}} results found", { count: resultItems.length })
@@ -245,7 +245,9 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
{resultItems.length > 0 && <>{resultItems}</>} {resultItems.length > 0 && <>{resultItems}</>}
{(query.length > 0 || isFilterBrowse) && isFetching && ( {(query.length > 0 || isFilterBrowse) &&
isFetching &&
resultItems.length === 0 && (
<Spotlight.Empty> <Spotlight.Empty>
<Text size="sm" style={{ marginTop: 10 }}> <Text size="sm" style={{ marginTop: 10 }}>
{t("Searching...")} {t("Searching...")}
@@ -42,6 +42,8 @@ export class SearchService {
const searchQuery = tsquery(query + '*'); const searchQuery = tsquery(query + '*');
const titleOnly = searchParams.titleOnly === true; const titleOnly = searchParams.titleOnly === true;
const titleQuery = query; const titleQuery = query;
// escape LIKE wildcards; ranking keeps the raw query
const titleLikeQuery = query.replace(/[\\%_]/g, '\\$&');
const rankColumn = browseByFilters const rankColumn = browseByFilters
? sql<number>`0`.as('rank') ? sql<number>`0`.as('rank')
@@ -84,7 +86,7 @@ export class SearchService {
eb( eb(
sql`lower(f_unaccent(pages.title))`, sql`lower(f_unaccent(pages.title))`,
'like', '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)); queryResults = queryResults.select((eb) => this.pageRepo.withSpace(eb));
} }
if (searchParams.spaceId) { if (searchParams.spaceId && opts.userId) {
// search by spaceId
queryResults = queryResults.where('spaceId', '=', searchParams.spaceId); queryResults = queryResults.where('spaceId', '=', searchParams.spaceId);
} else if (opts.userId && !searchParams.spaceId) { } else if (opts.userId && !searchParams.spaceId) {
// only search spaces the user is a member of // only search spaces the user is a member of
-1
View File
@@ -312,7 +312,6 @@ export interface PageHistory {
export interface Pages { export interface Pages {
content: Json | null; content: Json | null;
contributorIds: Generated<string[] | null>; contributorIds: Generated<string[] | null>;
labelIds: Generated<string[] | null>;
coverPhoto: string | null; coverPhoto: string | null;
createdAt: Generated<Timestamp>; createdAt: Generated<Timestamp>;
creatorId: string | null; creatorId: string | null;