Add cross-property BM25 And operator - #2114
Open
amourao wants to merge 1 commit into
Open
Conversation
Exposes the OPERATOR_AND_CROSS search operator added in Weaviate 1.39.0 (backported to 1.37.15 and 1.38.8) as `BM25Operator.and_cross()`. Unlike `and_()`, a query token may be matched by any of the searched properties instead of having to occur within a single one. The gRPC construction for the bm25 and hybrid paths is folded into a shared `_BaseGRPC._bm25_operator_to_grpc()` so the version gate applies to query, generative-query and aggregation alike; sending the new enum to a server that predates it raises WeaviateUnsupportedFeatureError. `_ServerVersion.is_at_least_any()` is added to express minimums that were backported across several release branches.
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Secrets | View in Orca |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev/1.39 #2114 +/- ##
===========================================
Coverage ? 88.29%
===========================================
Files ? 303
Lines ? 23397
Branches ? 0
===========================================
Hits ? 20659
Misses ? 2738
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Exposes the
OPERATOR_AND_CROSSsearch operator (Weaviate 1.39.0, backported to 1.37.15 and 1.38.8) asBM25Operator.and_cross(), available wherever a BM25 operator is accepted:query.bm25,query.hybrid, the generative-query equivalents, andaggregate.hybrid.Unlike
and_(), which requires every query token to occur within a single property,and_cross()lets a token be matched by any of the searched properties as long as each token is matched by at least one. All searched properties must share the same tokenization and analyzer settings — the server rejects the query otherwise.Changes
BM25OperatorAndCross+BM25Operator.and_cross()inweaviate/collections/classes/grpc.py.SearchOperatorOptionsconstruction in the bm25 and hybrid paths is folded into_BaseGRPC._bm25_operator_to_grpc(), so the version gate covers every caller. Usingand_cross()against an older server raisesWeaviateUnsupportedFeatureErrorrather than sending an enum value the server does not understand._ServerVersion.is_at_least_any()expresses a minimum that was backported across several release branches (a 1.38.x server needs 1.38.8, a 1.37.x server needs 1.37.15).OPERATOR_AND_CROSSenum value.1.39.0-rc.1-89299a5— the first RC carrying the operator.Tests
test/collection/test_bm25_operator.py— operator-to-gRPC wiring for bm25/hybrid/aggregate-hybrid, and the version gate across supported and unsupported versions.test/test_server_version.py—is_at_least_any()around each branch boundary.and_andor_, the mismatched-tokenization server error, and the unsupported-version path. All version-gated with skips.