From d139dfa15421a7d208b65aaeed0c5da3391a8440 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:50:28 +0000 Subject: [PATCH 1/2] Initial plan From b92613a7865fa76e08b28051642648874d74a86e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:58:59 +0000 Subject: [PATCH 2/2] Add "search for exact answer" mode to db search Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com> --- client/db/highlight-query.js | 4 ++-- client/db/index.jsx | 1 + database/qbreader/get-query.js | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/db/highlight-query.js b/client/db/highlight-query.js index ce31dfda2..222cf537f 100644 --- a/client/db/highlight-query.js +++ b/client/db/highlight-query.js @@ -10,7 +10,7 @@ export function highlightTossupQuery ({ tossup, regExp, searchType = 'all', igno tossup.question = insertHighlightTokensHelper(tossup.question, tossup.question_sanitized, word); } - if (searchType === 'answer' || searchType === 'all') { + if (searchType === 'answer' || searchType === 'exactAnswer' || searchType === 'all') { tossup.answer = insertHighlightTokensHelper(tossup.answer, tossup.answer_sanitized, word); } } @@ -31,7 +31,7 @@ export function highlightBonusQuery ({ bonus, regExp, searchType = 'all', ignore } } - if (searchType === 'answer' || searchType === 'all') { + if (searchType === 'answer' || searchType === 'exactAnswer' || searchType === 'all') { for (let i = 0; i < bonus.answers.length; i++) { bonus.answers[i] = insertHighlightTokensHelper(bonus.answers[i], bonus.answers_sanitized[i], word); } diff --git a/client/db/index.jsx b/client/db/index.jsx index 107e3c2ef..a45f8ff98 100644 --- a/client/db/index.jsx +++ b/client/db/index.jsx @@ -316,6 +316,7 @@ function QueryForm () { +
diff --git a/database/qbreader/get-query.js b/database/qbreader/get-query.js index 0695d2dba..7d5e8ef48 100644 --- a/database/qbreader/get-query.js +++ b/database/qbreader/get-query.js @@ -102,7 +102,7 @@ function validateOptions ({ if (!searchType) { searchType = 'all'; - } else if (!['question', 'answer', 'all'].includes(searchType)) { + } else if (!['question', 'answer', 'exactAnswer', 'all'].includes(searchType)) { throw new Error('Invalid search type specified.'); } @@ -184,6 +184,10 @@ async function getTossupQuery (options) { orQuery.push({ answer_sanitized: { $regex: word, $options: caseSensitive ? '' : 'i' } }); } + if (searchType === 'exactAnswer') { + orQuery.push({ answer_sanitized: { $regex: `^${word}`, $options: caseSensitive ? '' : 'i' } }); + } + andQuery.push({ $or: orQuery }); } @@ -225,6 +229,10 @@ async function getBonusQuery (options) { orQuery.push({ answers_sanitized: { $regex: word, $options: caseSensitive ? '' : 'i' } }); } + if (searchType === 'exactAnswer') { + orQuery.push({ answers_sanitized: { $regex: `^${word}`, $options: caseSensitive ? '' : 'i' } }); + } + andQuery.push({ $or: orQuery }); }