Skip to content

Fix quicksearch relevance to show exact matches first#1543

Open
JasonWildMe wants to merge 1 commit into
mainfrom
fix/quicksearch-relevance-1541
Open

Fix quicksearch relevance to show exact matches first#1543
JasonWildMe wants to merge 1 commit into
mainfrom
fix/quicksearch-relevance-1541

Conversation

@JasonWildMe
Copy link
Copy Markdown
Collaborator

@JasonWildMe JasonWildMe commented Apr 16, 2026

Summary

  • Fix quicksearch returning results in arbitrary order by adding boosted queries and sorting
  • Exact ID matches now appear first, followed by prefix matches, then partial matches
  • Addresses the issue where searching "CRC-6" would not show individual "CRC-6" in top results

Root Cause

The quicksearch used only wildcard queries which return constant scores (1.0), causing OpenSearch to return results in arbitrary order.

Changes

Query Type Field Boost Purpose
wildcard (exact) id 100 "CRC-6" matches "CRC-6" exactly
term names 80 Exact name match
wildcard (prefix) id 50 "CRC" matches "CRC-6", "CRC-123"
prefix names 40 Name starts with search term
wildcard (x) id 10 Partial ID match
wildcard (x) names 5 Partial name match
wildcard (x) encounterIds 1 Encounter ID contains term

Additional changes:

  • Added sort=id&sortOrder=asc for deterministic ordering
  • Added minimum_should_match: 1 for explicit query behavior
  • Used case_insensitive: true for ID field (no normalizer in mapping)

Test plan

  • Existing unit tests pass
  • Search "CRC-6" in Flukebook quicksearch - should show "CRC-6" as top result
  • Search partial terms - should still return relevant matches
  • Verify case-insensitive search works (e.g., "crc-6" finds "CRC-6")

Fixes #1541

The quicksearch was returning results in arbitrary order because wildcard
queries return constant scores (1.0). When searching "CRC-6", the exact
match individual might not appear in the top 10 results.

Changes:
- Add boosted queries: exact match (100) > prefix match (50) > wildcard (10/5/1)
- Add sort=id&sortOrder=asc for deterministic ordering when scores are equal
- Use case_insensitive wildcards for ID field (no normalizer in mapping)
- Use term/prefix for names field (has normalizer, lowercase works)
- Add minimum_should_match: 1 for explicit query behavior

Fixes #1541

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JasonWildMe JasonWildMe requested a review from naknomum April 16, 2026 05:14
@JasonWildMe JasonWildMe self-assigned this Apr 16, 2026
@naknomum naknomum added this to the 10.10.5 milestone May 5, 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.

quicksearch omits the top result from displaying

2 participants