mirror of
https://github.com/docmost/docmost.git
synced 2025-11-27 16:18:47 +10:00
WIP: indexing Chinese better
This commit is contained in:
@@ -36,7 +36,7 @@ export class SearchService {
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
sql<number>`ts_rank(tsv, to_tsquery(${searchQuery}))`.as('rank'),
|
||||
sql<string>`ts_headline('english', text_content, to_tsquery(${searchQuery}), 'MinWords=9, MaxWords=10, MaxFragments=10')`.as(
|
||||
sql<string>`ts_headline('chinese_zh', text_content, to_tsquery(${searchQuery}), 'MinWords=9, MaxWords=10, MaxFragments=10')`.as(
|
||||
'highlight',
|
||||
),
|
||||
])
|
||||
|
||||
@@ -4,8 +4,8 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
await sql`CREATE OR REPLACE FUNCTION pages_tsvector_trigger() RETURNS trigger AS $$
|
||||
begin
|
||||
new.tsv :=
|
||||
setweight(to_tsvector('english', coalesce(new.title, '')), 'A') ||
|
||||
setweight(to_tsvector('english', coalesce(new.text_content, '')), 'B');
|
||||
setweight(to_tsvector('chinese_zh', coalesce(new.title, '')), 'A') ||
|
||||
setweight(to_tsvector('chinese_zh', coalesce(new.text_content, '')), 'B');
|
||||
return new;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;`.execute(db);
|
||||
|
||||
@@ -18,7 +18,8 @@ services:
|
||||
- docmost:/app/data/storage
|
||||
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
#image: postgres:16-alpine
|
||||
image: abcfy2/zhparser:16-alpine
|
||||
environment:
|
||||
POSTGRES_DB: docmost
|
||||
POSTGRES_USER: docmost
|
||||
|
||||
Reference in New Issue
Block a user