Skip to content

core: fix inverted sort order in search relevance ranking#10081

Open
zigzagdev wants to merge 1 commit into
streetwriters:masterfrom
zigzagdev:fix/lookup-search-sort-bug
Open

core: fix inverted sort order in search relevance ranking#10081
zigzagdev wants to merge 1 commit into
streetwriters:masterfrom
zigzagdev:fix/lookup-search-sort-bug

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fix inverted sort comparators for relevance-based search results.

When sorting by relevance with sortDirection: "desc", the comparator used a.rank - b.rank (ascending) instead of b.rank - a.rank (descending), and vice versa.
This caused search results to show the least relevant results first by default.

The same issue existed in both note search (packages/core/src/api/lookup.ts:270) and trash search (lpackages/core/src/api/lookup.ts:710).

Type of Change

  • Bug fix
  • Feature

Visuals

  • Attached relevant screenshots / screen recording / GIF
  • N/A (not a feature or no UI changes)

Testing

  • Ran all E2E tests
  • Ran all integration tests
  • Added/updated tests for this change (if needed)
  • N/A (tests not needed — explanation provided below)

If tests were not added, explain why

Two-line fix swapping comparator operands. Existing search tests cover result matching but not sort order.
But if tests are required in this PR, I'll add it.

Platform

  • Web
  • Mobile
  • Desktop

Sign-off

  • QA passed
  • UI/UX 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.

1 participant