Skip to content

SCIX-889 fix(search): sort operator queries by score instead of user preference#889

Merged
thostetler merged 2 commits into
adsabs:masterfrom
thostetler:fix/scix-889-second-order-query-sort
Jun 22, 2026
Merged

SCIX-889 fix(search): sort operator queries by score instead of user preference#889
thostetler merged 2 commits into
adsabs:masterfrom
thostetler:fix/scix-889-second-order-query-sort

Conversation

@thostetler

@thostetler thostetler commented Jun 17, 2026

Copy link
Copy Markdown
Member

Manually typing a second-order operator query (trending, reviews, useful, similar) used the user's saved default sort instead of score desc. The Explore menu path already injected the correct sort; only the manual submit handlers were affected.

  • Adds getDefaultSortForQuery() to the search utils — returns score desc for operator queries, fallback sort for everything else
  • Applies at both submit handlers: home page and search page
  • Adds unit tests for operator detection and regular query passthrough

…preference

Second-order operator queries (trending, reviews, useful, similar) were
sorted by the user's saved default sort instead of relevance score. Added
getDefaultSortForQuery() to detect these operators and apply score desc at
both submit sites (home page and search page), matching the Explore menu path.
@thostetler thostetler requested a review from shinyichen June 17, 2026 18:58
@thostetler thostetler marked this pull request as ready for review June 17, 2026 18:58
Copilot AI review requested due to automatic review settings June 17, 2026 18:58
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.0%. Comparing base (e1e3cc5) to head (c29e000).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #889     +/-   ##
========================================
+ Coverage    64.2%   66.0%   +1.9%     
========================================
  Files         350     338     -12     
  Lines       41492   40070   -1422     
  Branches     2010    2024     +14     
========================================
- Hits        26602   26424    -178     
+ Misses      14847   13604   -1243     
+ Partials       43      42      -1     
Files with missing lines Coverage Δ
src/utils/common/search.ts 95.7% <100.0%> (+0.2%) ⬆️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Risk summary: Low-to-medium regression risk. The behavior change is small and well-targeted, but the new operator-detection regex may be overly permissive and could override sort for some non-operator queries.

Findings (priority order):

  • medium — Operator detection regex can match operator tokens inside fielded/quoted queries and unintentionally override sort.
    • Impact: users could lose their intended sort for queries that merely contain trending(/reviews( etc. as text.
    • Location: src/utils/common/search.ts:178
    • Minimal fix: constrain detection to start-of-string or whitespace (optionally allowing leading +/-).
    • Confidence: medium

Changes:

  • Added getDefaultSortForQuery() to force score desc for second-order operator queries, otherwise preserve a fallback sort.
  • Applied the sort override logic to manual submit handlers on both the home page and the search page.
  • Added unit tests covering operator detection and passthrough behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/utils/common/search.ts Adds query-aware default sort selection for second-order operators.
src/utils/common/tests/search.test.ts Adds unit tests validating operator detection and fallback behavior.
src/pages/search/index.tsx Uses query-aware default sort on manual submit from the search page.
src/pages/index.tsx Uses query-aware default sort on manual submit from the home page.

Comment thread src/utils/common/search.ts Outdated
@thostetler thostetler merged commit 6a1cfcf into adsabs:master Jun 22, 2026
5 checks passed
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.

3 participants