Skip to content

Release: search regression fixes - #501

Merged
neuromechanist merged 4 commits into
mainfrom
dev
May 14, 2026
Merged

neuromechanist merged 4 commits into
mainfrom
dev

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Merges the search fixes from dev → main to ship to production.

Includes:

Once merged, auto-tag.yml will strip the -dev1 suffix from package.json, tag v0.8.16, and deploy-backend.yml will roll out the Worker to SCCN production. After that:

# Should return Healthy Brain Network EEG with method=exact_id
curl 'https://api.nemar.org/datasets/search?q=nm000103'

# Should return Ear-EEG Sleep Monitoring datasets ranked first
curl 'https://api.nemar.org/datasets/search?q=sleep%20eeg'

Test plan

  • Dev backend deploy succeeded
  • Dev verified: exact-ID returns the correct row with method=exact_id
  • Dev verified: catalog-sync workflow ran green on the feature branch
  • Prod deploy succeeds after merge
  • Prod search returns expected results

nemar-bot and others added 4 commits May 14, 2026 18:15
…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
@neuromechanist
neuromechanist enabled auto-merge May 14, 2026 19:36
@neuromechanist
neuromechanist merged commit 5b927a4 into main May 14, 2026
21 checks passed

This branch was previously deployed

2 inactive deployments
development — 1bad957e Deployed May 14, 2026 by neuromechanist via deploy-dev #281
npm — 1bad957e Deployed May 14, 2026 by neuromechanist via publish #902
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