Skip to content

Default search rankings to Relevance for bills and testimonies - #2241

Open
fastfadingviolets wants to merge 2 commits into
codeforboston:mainfrom
hyphacoop:search-default-relevance
Open

fastfadingviolets wants to merge 2 commits into
codeforboston:mainfrom
hyphacoop:search-default-relevance

Conversation

@fastfadingviolets

Copy link
Copy Markdown
Contributor

Summary

"Sort by relevance" used to be undefined & a TypeScript default, but ever since #2227, it's actually defined for bills, hearings, and testimonies. It weighs based on the score of the hit & then tiebreaks by recency for testimonies & recency of last testimony for bills. This switches the default ordering to be relevance for testimonies & bills (hearings are untouched as a chronological sort makes more sense for hearings).

Checklist

  • On the frontend, I've made my strings translate-able.
  • If I've added shared components, I've added a storybook story.
  • I've made pages responsive and look good on mobile.
  • If I've added new Firestore queries, I've added any new required indexes to firestore.indexes.json (Please do not only create indexes through the Firebase Web UI, even though the error messages may reccommend it - indexes created this way may be obliterated by subsequent deploys)

Screenshots

image image

Known issues

If you've run against limitations or caveats, include them here. Include follow-up issues as well.

Steps to test/reproduce

For each feature or bug fix, create a step by step list for how a reviewer can test it out. E.g.:

  1. Go to the home page
  2. Click on a testimony
  3. See that it's loaded with a loading spinner

fastfadingviolets and others added 2 commits September 10, 2026 15:45
The default was "Sort by Most Recent Testimony", a pure recency sort in
which text relevance plays no part. A query like "liquor" expands through
the legislative synonym set to "alcohol" and matches hundreds of bills in
their full text, and under that sort the page led with whichever weak
body-text match had the newest testimony: the budget, a tax-cap bill, a
tenant bill.

Relevance is now the first option and the default. Its index name is the
bare "bills" collection rather than "bills/sort/<sort_by>", and BillSearch
pins billsRelevanceSort as the adapter's sort_by: the adapter falls back
to that whenever the index name has no sort segment. That keeps the _eval
clause out of every Browse Bills URL, which is keyed by index name, so a
default page reads bills[query]=liquor. The other options keep their sort
in the index name and override the pinned one as before. The eval-shared
billsSearchParams is unchanged, so the harness sends exactly what it did.

The default index name lives next to the sort options, and BillSearch and
billSearchByTopicLink both key on it instead of a hard-coded string; the
topic links previously carried the old latestTestimonyAt key and would
otherwise have landed on the page with no refinements.

billsRelevanceSort itself is unchanged and the bills golden set scores
byte-identical to the bills-order-demotion baseline. The empty-query
landing page now orders non-procedural bills by testimony count, the
sort's tiebreaker.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QeZFi8CjMyJixcm5CbGUzq
Same change as for bills, same mechanism. Relevance is the first option
and the default, keyed on the bare "publishedTestimony" collection with
testimonyRelevanceSort pinned as the adapter's sort_by, so the sort string
stays out of the page's URLs. Newest and Oldest keep their sort in the
index name and override it as before.

The landing page does not change: with no query every document's text
match is equal, so the relevance sort falls through to its publishedAt
tiebreak and reads newest-first exactly as the old default did. With a
query, weak matches no longer win on date alone.

Hearings keep their date-windowed default, since "past, newest first" is
a view with a time filter rather than a sort.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QeZFi8CjMyJixcm5CbGUzq
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maple-dev Ready Ready Preview Sep 10, 2026 9:28pm UTC

Request Review

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.

1 participant