[questions][feat] update text search (#511)

pull/519/head
hpkoh 2 years ago committed by GitHub
parent 9c18cb28e8
commit 8f4246da6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
`;
}

Loading…
Cancel
Save