mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-04-04 19:39:43 +08:00
[questions][feat] update text search (#511)
This commit is contained in:
@@ -235,9 +235,8 @@ export const questionsQuestionRouter = createRouter()
|
||||
.$queryRaw`
|
||||
SELECT id FROM "QuestionsQuestion"
|
||||
WHERE
|
||||
to_tsvector("content") @@ to_tsquery('english', ${query})
|
||||
ORDER BY ts_rank_cd(to_tsvector("content"), to_tsquery('english', ${query}), 4) DESC
|
||||
LIMIT 3;
|
||||
ts_rank_cd(to_tsvector("content"), to_tsquery(${query}), 32) > 0.7
|
||||
ORDER BY ts_rank_cd(to_tsvector("content"), to_tsquery('english', ${query}), 4) DESC;
|
||||
`;
|
||||
|
||||
const relatedQuestionsIdArray = relatedQuestionsId.map(
|
||||
@@ -315,9 +314,8 @@ export const questionsQuestionRouter = createRouter()
|
||||
.$queryRaw`
|
||||
SELECT id FROM "QuestionsQuestion"
|
||||
WHERE
|
||||
to_tsvector("content") @@ to_tsquery('english', ${query})
|
||||
ORDER BY ts_rank_cd(to_tsvector("content"), to_tsquery('english', ${query}), 4) DESC
|
||||
LIMIT 3;
|
||||
ts_rank_cd(to_tsvector("content"), to_tsquery(${query}), 32) > 0.7
|
||||
ORDER BY ts_rank_cd(to_tsvector("content"), to_tsquery('english', ${query}), 4) DESC;
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user