[questions][feat] update text search

pull/511/head
hpkoh 3 years ago
parent 32302e33a5
commit e3d57771ea

@ -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