fix(graph): prioritize exact name match in /graph facts query#1493
Merged
fix(graph): prioritize exact name match in /graph facts query#1493
Conversation
FTS5 search could return an entity whose summary mentions the searched name instead of the entity with that exact name. For example, `/graph facts Alice` returned "Google" because Google's summary contained "Alice". Implement two-phase lookup in find_entity_by_name: 1. Exact case-insensitive match on name/canonical_name (direct SQL query) 2. FTS5 prefix search fallback only when no exact match found Closes #1472
Add test for canonical_name branch in find_entity_by_name exact-match phase and update CHANGELOG.md [Unreleased].
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.
Summary
Fixes
/graph facts <name>returning the wrong entity when another entity's summary mentions the searched name.find_entity_by_namenow uses a two-phase lookup: exact case-insensitive match onname/canonical_namefirst, FTS5 prefix search only as fallbackRoot Cause
FTS5 searched both
nameandsummarycolumns. Even with a 10x BM25 weight onname, an entity with the search term appearing multiple times in its summary could outscore an entity with that exact name.Test Plan
cargo nextest run -p zeph-memory -E 'test(find_entity_by_name)'— 5/5 passcargo nextest run --workspace --features full --lib --bins— 4939/4939 passcargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— cleanCloses #1472