Repository navigation
Release: search regression fixes - #501
Merged
Merged
Conversation
…pass (#500) * fix(search): fall back to D1 text search and short-circuit exact IDs The /datasets/search handler only consulted Vectorize when the AI and VECTORIZE bindings were present, and returned its (often empty) result verbatim. That meant: - Literal dataset IDs like nm000103 always missed, because an embedding model cannot meaningfully match an opaque identifier. - When the Vectorize index is empty or stale, search returned zero hits even though the D1 nemar_catalog table held the matching rows. Three small adjustments fix both: 1. Exact dataset-ID queries (nm###### / ds######) take an early D1 lookup with method=exact_id, skipping the embedding step. 2. When semantic search returns zero hits, fall back to textSearch instead of returning an empty list (method=text_fallback). 3. When semantic returns hits, also merge in textSearch matches it missed, preserving the ranked semantic order at the head. * ci(catalog-sync): post to workers.dev hostname to bypass zone WAF The custom-domain api.nemar.org sits behind Cloudflare's zone-level bot management, which 403s the ~2.5 MB catalog POST from GitHub-runner IPs (the 403 body is a Cloudflare challenge token, not a Worker response — the request never reaches the admin middleware). The workers.dev hostname hits the same Worker, D1, and Vectorize bindings but skips the zone WAF, and /admin/catalog/sync is already protected by the ADMIN_API_KEY check on the worker side. * fix(search): drop low-relevance semantic hits below 0.65 cosine Without a relevance floor, semantic search returns up to limit*2 hits regardless of how well they actually match. With bge-small-en-v1.5 against the NEMAR catalog, cosine scores below ~0.65 are topic-adjacent noise (e.g. any EEG dataset coming back for 'sleep eeg', or arbitrary motor-imagery datasets for the literal ID 'nm000103'). - Add DEFAULT_MIN_SCORE = 0.65 floor on semantic results - Allow per-request override via ?min_score=0..1 query param - Text-search hits get score=1.0 so the floor is a no-op for them - Surface the active threshold in the response so callers know what was applied - Update CLI DatasetSearchResponse type to include the new method values (exact_id, unavailable) and the optional min_score field
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merges the search fixes from dev → main to ship to production.
Includes:
Once merged,
auto-tag.ymlwill strip the-dev1suffix from package.json, tagv0.8.16, anddeploy-backend.ymlwill roll out the Worker to SCCN production. After that:Test plan