mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
wip: Replace tsvector with trigram search
This commit is contained in:
parent
59aca6d520
commit
eaec881594
@ -295,15 +295,8 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
|
||||
isAvailable: sql<boolean>`${videoQ.showPk} is not null`.as(
|
||||
"isAvailable",
|
||||
),
|
||||
rank: sql<number>`ts_rank_cd(${transQ.search}, query)`.as("rank"),
|
||||
})
|
||||
.from(shows)
|
||||
// TODO: change `simple` to `transQ.language`
|
||||
// yes drizzle doesn't support crossJoin so we do a fullJoin on true T-T
|
||||
.fullJoin(
|
||||
sql`websearch_to_tsquery('simple', ${query}) as query`,
|
||||
sql`true`,
|
||||
)
|
||||
.innerJoin(transQ, eq(shows.pk, transQ.pk))
|
||||
.leftJoin(
|
||||
showTranslations,
|
||||
@ -318,12 +311,14 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
|
||||
.where(
|
||||
and(
|
||||
filter,
|
||||
query ? sql`query @@ ${transQ.search}` : undefined,
|
||||
query ? sql`${query}::text %> ${showTranslations.name}` : undefined,
|
||||
keysetPaginate({ table: shows, after, sort }),
|
||||
),
|
||||
)
|
||||
.orderBy(
|
||||
...(query ? [sql`rank`] : []),
|
||||
...(query
|
||||
? [sql`word_similarity(${query}::text, ${showTranslations.name})`]
|
||||
: []),
|
||||
...(sort.random
|
||||
? [sql`md5(${sort.random.seed} || ${shows.pk})`]
|
||||
: []),
|
||||
|
Loading…
x
Reference in New Issue
Block a user