Skip to content

Add "Exact answer" search type to DB search#449

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-exact-answer-search-mode
Draft

Add "Exact answer" search type to DB search#449
Copilot wants to merge 2 commits intomainfrom
copilot/add-exact-answer-search-mode

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Adds a new exactAnswer option to the search type dropdown, allowing users to find questions whose answer field starts with the query string. Unlike the existing answer type (substring match), this anchors the regex to the start of answer_sanitized/answers_sanitized, which aligns with quizbowl answer format where accept/prompt qualifiers follow the main answer in brackets (e.g., Albert Einstein [accept Einstein; ...]).

Changes

  • database/qbreader/get-query.js

    • Added 'exactAnswer' to valid searchType values
    • getTossupQuery: matches answer_sanitized with ^${word} when searchType === 'exactAnswer'
    • getBonusQuery: matches answers_sanitized with ^${word} when searchType === 'exactAnswer'
  • client/db/highlight-query.js: treats exactAnswer like answer for result highlighting

  • client/db/index.jsx: adds <option value='exactAnswer'>Exact answer</option> to the search type <select>

The effective MongoDB query for tossups when using exactAnswer:

{ answer_sanitized: { $regex: `^${escapedQuery}`, $options: 'i' } }
Original prompt

This section details on the original issue you should resolve

<issue_title>Add "search for exact answer" mode to db search</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: geoffrey-wu <42471355+geoffrey-wu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add 'search for exact answer' mode to database search Add "Exact answer" search type to DB search Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "search for exact answer" mode to db search

2 participants