Skip to content

fix: Uploaded document is not retrievable/searchable using its unique content. #1183

Merged
Wallgau merged 6 commits into
release-0.4.0from
search-relevance-clean-r040
Mar 21, 2026
Merged

fix: Uploaded document is not retrievable/searchable using its unique content. #1183
Wallgau merged 6 commits into
release-0.4.0from
search-relevance-clean-r040

Conversation

@Wallgau

@Wallgau Wallgau commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

issue: #1138

Improved Knowledge search relevance and partial-query handling by tuning frontend threshold defaults and backend hybrid query behavior.
Before:
Default scoreThreshold was effectively 0 when not provided, so low-relevance files were often included.
Short partial queries (like vita) often returned nothing.
Unique terms could still return unrelated files due to semantic spillover.
Returned total could reflect raw backend hits instead of post-filtered displayed results.
https://github.com/user-attachments/assets/47b4ff45-62a4-473d-b440-e1b82720be9e

Now:
Default scoreThreshold is 1.25 (frontend), with dynamic relaxation to 1.0 for short single-token queries (<=4 chars).
Backend keyword branch is stricter (operator: and, fuzziness: AUTO:4,7) and includes bool_prefix support for partials.
Added exact-text file preference: if query appears verbatim in specific files, results are narrowed to those files.
Fixed exact-file filtering robustness (only valid string filenames considered).
total now matches the actual filtered results shown (len(chunks)).
https://github.com/user-attachments/assets/7d073caf-c00d-41ee-aaa7-6a3735d86a91

Improve hybrid search quality with a default score threshold, short-query threshold relaxation, prefix matching support, and exact-file preference for unique query text.

Made-with: Cursor
@github-actions github-actions Bot added frontend 🟨 Issues related to the UI/UX backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. labels Mar 18, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 19, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 19, 2026
@ricofurtado ricofurtado requested a review from Copilot March 19, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Knowledge search precision for unique/partial queries by tightening keyword matching, adding prefix matching support, and adjusting default score-threshold behavior to reduce low-relevance results.

Changes:

  • Backend: tune hybrid keyword queries (AND + stricter fuzziness + bool_prefix) and post-filter results to prefer files containing the query verbatim.
  • Backend: adjust total to reflect the post-filtered result set size.
  • Frontend: introduce a default score threshold (with dynamic relaxation for short single-token queries) and apply it when scoreThreshold is not provided.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/services/search_service.py Tightens OpenSearch hybrid keyword behavior, adds exact-match file preference filtering, and changes total semantics.
frontend/lib/constants.ts Adds a default score threshold constant for Knowledge search.
frontend/app/api/queries/useGetSearchQuery.ts Applies the new default threshold and dynamically relaxes it for short single-token queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/services/search_service.py
)
}
if exact_files:
chunks = [chunk for chunk in chunks if chunk.get("filename") in exact_files]
Comment thread src/services/search_service.py
Comment thread src/services/search_service.py Outdated
Comment thread src/services/search_service.py
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 19, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 19, 2026
Use safer prefix fallback behavior for current index mappings and keep aggregations aligned with post-filtered exact file results.

Made-with: Cursor
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 19, 2026
@Wallgau Wallgau requested a review from ricofurtado March 19, 2026 23:45
@github-actions github-actions Bot added the lgtm label Mar 21, 2026
@Wallgau Wallgau merged commit 529c4d0 into release-0.4.0 Mar 21, 2026
8 checks passed
@github-actions github-actions Bot deleted the search-relevance-clean-r040 branch March 21, 2026 01:10
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. frontend 🟨 Issues related to the UI/UX lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants