mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-07 20:44:54 +08:00
[qeustions][chore] update text search
This commit is contained in:
@@ -319,8 +319,6 @@ export const questionsQuestionRouter = createProtectedRouter()
|
||||
.query('getRelatedQuestionsByContent', {
|
||||
input: z.object({
|
||||
content: z.string(),
|
||||
pageNum: z.number(),
|
||||
pageSize: z.number(),
|
||||
}),
|
||||
async resolve({ ctx, input }) {
|
||||
const escapeChars = /[()|&:*!]/g;
|
||||
@@ -333,11 +331,10 @@ export const questionsQuestionRouter = createProtectedRouter()
|
||||
.join(" | ");
|
||||
|
||||
const relatedQuestions = await ctx.prisma.$queryRaw`
|
||||
SELECT content FROM "QuestionsQuestion"
|
||||
SELECT * FROM "QuestionsQuestion"
|
||||
WHERE
|
||||
"contentSearch" @@ to_tsquery('english', ${query})
|
||||
ORDER BY ts_rank("textSearch", to_tsquery('english', ${query})) DESC
|
||||
LIMIT 10;
|
||||
`;
|
||||
|
||||
return relatedQuestions;
|
||||
|
||||
Reference in New Issue
Block a user