mirror of
https://github.com/docmost/docmost.git
synced 2026-08-25 15:57:11 +08:00
minor search filter fixes
This commit is contained in:
@@ -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<number>`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
|
||||
|
||||
-1
@@ -312,7 +312,6 @@ export interface PageHistory {
|
||||
export interface Pages {
|
||||
content: Json | null;
|
||||
contributorIds: Generated<string[] | null>;
|
||||
labelIds: Generated<string[] | null>;
|
||||
coverPhoto: string | null;
|
||||
createdAt: Generated<Timestamp>;
|
||||
creatorId: string | null;
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: 0be4a76175...b51a46ef10
Reference in New Issue
Block a user