fix(query): keep field-filtered searches off the chunk-rerank path #23
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/rerank-field-filters"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #22.
A NIP-50 search combining free text with a field filter (
"forschung publisher.name:e-teaching.org", or"<topic> community:<pubkey>") was routed to chunk-rerank, which sends the raw search string to the chunk index — the filter tokens are read as text, and thefilter.Matchespost-filter ignores theSearchfield, so the field filter was silently dropped and the query answered wider than asked. Verified live on wss://amb-relay.edufeed.org:"LADEN publisher.name:zzz-bogus-control-xyz"returned free-text hits instead of 0.Pure field-filter searches were already protected by the
searchHasFreeTextguard; the combined case leaked.Change: new
registry.rerankOwns(filter)encodes the full ownership rule — chunked target + free text + no field filters — with a table test (TestRerankOwnsSearch) covering the leaking case;QueryStoreduses it. Field-filtered searches now take the plain Typesense path, which honours the filter and loses only passage ordering and snippets: fail closed on ranking, never on filtering.Trade-off / follow-up: community- or publisher-scoped topic searches no longer get chunk-level snippets. Restoring rerank for filtered searches would mean stripping field filters from the chunk query and intersecting with the filtered lexical set (option 2 in #22) — left for a follow-up.
Note:
TestSharesBackendFilterExpressionsfails identically on cleanmain(pre-existing, unrelated); everything else passes with this change.🤖 Generated with Claude Code
A NIP-50 search combining free text with a field filter ("forschung publisher.name:e-teaching.org") was routed to chunk-rerank, which sends the raw search string to the chunk index — the filter tokens are read as text and filter.Matches never re-applies NIP-50 field filters, so the field filter was silently dropped and the query answered wider than asked. Verified live: "LADEN publisher.name:zzz-bogus" returned free-text hits instead of zero. Pure field-filter searches were already protected; the combined case leaked. New registry.rerankOwns encodes the full ownership rule (chunked target + free text + NO field filters); QueryStored uses it. Filtered searches now take the plain Typesense path, which honours the filter and loses only passage ordering and snippets — fail closed on ranking, never on filtering. Carrying filters through the rerank (intersecting with the filtered lexical set) can restore snippets for these searches later. Closes #22 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>