merge: TSVector based search provider (!910)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/910 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
93ffd4611c
3 changed files with 18 additions and 2 deletions
|
|
@ -254,7 +254,7 @@ export type Config = {
|
|||
};
|
||||
};
|
||||
|
||||
export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch';
|
||||
export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch' | 'sqlTsvector';
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
const _dirname = dirname(_filename);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ export class SearchService {
|
|||
): Promise<MiNote[]> {
|
||||
switch (this.provider) {
|
||||
case 'sqlLike':
|
||||
case 'sqlPgroonga': {
|
||||
case 'sqlPgroonga':
|
||||
case 'sqlTsvector': {
|
||||
// ほとんど内容に差がないのでsqlLikeとsqlPgroongaを同じ処理にしている.
|
||||
// 今後の拡張で差が出る用であれば関数を分ける.
|
||||
return this.searchNoteByLike(q, me, opts, pagination);
|
||||
|
|
@ -280,6 +281,8 @@ export class SearchService {
|
|||
|
||||
if (this.config.fulltextSearch?.provider === 'sqlPgroonga') {
|
||||
query.andWhere('note.text &@~ :q', { q });
|
||||
} else if (this.config.fulltextSearch?.provider === 'sqlTsvector') {
|
||||
query.andWhere('note.tsvector_embedding @@ websearch_to_tsquery(:q)', { q });
|
||||
} else {
|
||||
query.andWhere('note.text ILIKE :q', { q: `%${ sqlLikeEscape(q) }%` });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue