Skip to content

fix: prevent partial matches for exact token searches#2003

Open
NishadA05 wants to merge 3 commits into
mainfrom
fix-exact-knowledge-search-main
Open

fix: prevent partial matches for exact token searches#2003
NishadA05 wants to merge 3 commits into
mainfrom
fix-exact-knowledge-search-main

Conversation

@NishadA05

@NishadA05 NishadA05 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Cherry-picks the exact-token search fix from release-0.5.1 into main.

This prevents exact-looking token queries from returning partial or fuzzy matches when the exact token does not appear in the returned filename or chunk text.

Testing

uv run python -m py_compile src/services/search_service.py

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Improved search behavior for short or identifier-like queries so results now stay exact and avoid broader unrelated matches.
  * When no exact file matches are found for these queries, search now returns no snippets instead of showing loosely related content.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@github-actions github-actions Bot added the backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) label Jul 2, 2026
@github-actions github-actions Bot added the bug 🔴 Something isn't working. label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7692283-d709-4c1e-ab15-6846dda05558

📥 Commits

Reviewing files that changed from the base of the PR and between 903af2f and b09843b.

📒 Files selected for processing (1)
  • src/services/search_service.py
💤 Files with no reviewable changes (1)
  • src/services/search_service.py

Walkthrough

Adds regex-based token query classification to the search service and updates search result post-processing so token-like queries return no chunks when no exact file matches are found.

Changes

Exact Token Match Filtering

Layer / File(s) Summary
Token detection and exact-match filtering
src/services/search_service.py
Adds the re import, introduces _is_exact_token_query, and extends search_tool filtering to return empty chunks for token-like queries without exact_files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels

enhancement, search

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: tightening exact-token searches to avoid partial matches.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-exact-knowledge-search-main

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jul 2, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jul 2, 2026
@github-actions github-actions Bot added the lgtm label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants