feat: Warn when a similarity query does not use the vector index - #5197
Closed
islamaliev wants to merge 13 commits into
Closed
feat: Warn when a similarity query does not use the vector index#5197islamaliev wants to merge 13 commits into
islamaliev wants to merge 13 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5197 +/- ##
===========================================
+ Coverage 76.36% 76.41% +0.04%
===========================================
Files 648 648
Lines 51753 51753
===========================================
+ Hits 39521 39542 +21
+ Misses 8896 8881 -15
+ Partials 3336 3330 -6
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
…unused-vector-index
…unused-vector-index
…unused-vector-index
Contributor
Author
|
is already resolved as part of #5189 |
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.
Relevant issue(s)
Resolves #5173
Description
A similarity query uses the vector index only in one shape: a single similarity field, ordered by it descending, with a limit and no filter. Miss any of those and the query still returns the right answer, it just reads the whole collection on the way. Nothing in the response said so, so a query that looks fine in development gets slower as the collection grows.
It now reports a warning in
extensionsnaming which part of the shape ruled the index out, so the author knows what to change. A field with no vector index does not warn, since there is nothing to fall back from.This also fixes a separate bug it uncovered, worth reviewing on its own. A filtered similarity query was reaching the index when it should not have: the guard against it read the filter from a field that is already cleared by that point, so it never fired. The index returned the nearest documents, the filter then rejected some or all of them, and nothing refilled the gap, so the query could return fewer documents than match, sometimes none, while matching documents sat there unreturned. It now reads the filter from where it actually lives. This is on
developtoday.Draft until #5189 merges, which this builds on.
Tasks
How has this been tested?
Integration tests for each shape that falls back, plus the shape the index serves as the control, so the tests fail if every query starts warning. Test support was added so a request asserts its warnings, with expecting none as the default, which caught existing tests that had started warning.
The fallback tests run on the HTTP, CLI and C clients. That is what proves the warning survives serialization, which the extensions work could not test on its own.
The data loss fix has a regression test that fails without it: a filter matching one document the graph would not have returned.
Full integration suite green.
Specify the platform(s) on which this was tested: