Repository navigation
Conversation
…wildcards) corpus.grep interpolated user search terms raw into LIKE '%...%', so percent, underscore and backslash acted as wildcards despite the exact string search contract (a term like 30% matched 30X-style prefixes). Escape LIKE metacharacters and attach an escape character so terms match literally. Adds escaping unit tests and provisions the grep fakes for the scanned-page OCR probe the empty-result path now runs.
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.
Problem
corpus.grepinterpolated user search terms raw into SQLLIKE '%...%'. Because LIKE treats%,_, and backslash as wildcards,a term like
30%matched30X-style prefixes instead of a literal30%— contradicting the tool's advertised exact-string-search contract.Fix
Added
_escape_like_literalwhich escapes backslash, percent, and underscore,and attached an
ESCAPE '\'clause to the LIKE predicate so user terms matchliterally.
Verification
make lintpasses on shared-pythonshared/tests/test_agent_tools_grep.py: 22 passed (added escaping tests +fixed two grep fakes that under-provisioned the scanned-page OCR probe the
empty-result path now runs)
main for reasons unrelated to this change (pre-existing, CI-excluded)
Base: upstream/main. Head: Ayush7614/knowhere fix/ayush7614/corpus-grep-exact-string