Skip to content

Commit f026c1e

Browse files
authored
Adding latest 8.4 image to test matrix. Updating the Hybrid VSIM query format to be in sync with spec after srv issue was fixed. (#3843)
1 parent a5ab18f commit f026c1e

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
max-parallel: 15
7777
fail-fast: false
7878
matrix:
79-
redis-version: ['8.4-RC1-pre.2', '${{ needs.redis_version.outputs.CURRENT }}', '8.0.2' ,'7.4.4', '7.2.9']
79+
redis-version: ['8.4-GA-pre.2', '${{ needs.redis_version.outputs.CURRENT }}', '8.0.2' ,'7.4.4', '7.2.9']
8080
python-version: ['3.10', '3.14']
8181
parser-backend: ['plain']
8282
event-loop: ['asyncio']

redis/commands/search/hybrid_query.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def __init__(
7777
vsim_search_method: Optional[VectorSearchMethods] = None,
7878
vsim_search_method_params: Optional[Dict[str, Any]] = None,
7979
filter: Optional["Filter"] = None,
80+
yield_score_as: Optional[str] = None,
8081
) -> None:
8182
"""
8283
Create a new hybrid vsim query object.
@@ -96,8 +97,7 @@ def __init__(
9697
Example for RANGE: {"RADIUS": 10, "EPSILON": 0.1}
9798
where RADIUS is mandatory and defines the radius of the search
9899
and EPSILON is optional and defines the accuracy of the search.
99-
For both KNN and RANGE, the following parameter is optional:
100-
YIELD_SCORE_AS: The name of the field to yield the calculated score as.
100+
yield_score_as: The name of the field to yield the score as.
101101
102102
filter: If defined, a filter will be applied on the vsim query results.
103103
"""
@@ -108,6 +108,7 @@ def __init__(
108108
else:
109109
self._vsim_method_params = None
110110
self._filter = filter
111+
self._yield_score_as = yield_score_as
111112

112113
def vector_field(self) -> str:
113114
"""Return the vector field name of this query object."""
@@ -149,12 +150,21 @@ def filter(self, flt: "HybridFilter") -> "HybridVsimQuery":
149150
self._filter = flt
150151
return self
151152

153+
def yield_score_as(self, alias: str) -> "HybridVsimQuery":
154+
"""
155+
Return the score as a field with name `alias`.
156+
"""
157+
self._yield_score_as = alias
158+
return self
159+
152160
def get_args(self) -> List[str]:
153161
args = ["VSIM", self._vector_field, self._vector_data]
154162
if self._vsim_method_params:
155163
args.extend(self._vsim_method_params)
156164
if self._filter:
157165
args.extend(self._filter.args)
166+
if self._yield_score_as:
167+
args.extend(("YIELD_SCORE_AS", self._yield_score_as))
158168

159169
return args
160170

tests/test_asyncio/test_search.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,11 +2636,8 @@ async def test_hybrid_search_query_with_combine_all_score_aliases(self, decoded_
26362636
vector_field_name="@embedding-hnsw",
26372637
vector_data="abcd1234efgh5678",
26382638
vsim_search_method=VectorSearchMethods.KNN,
2639-
vsim_search_method_params={
2640-
"K": 3,
2641-
"EF_RUNTIME": 1,
2642-
"YIELD_SCORE_AS": "vsim_score",
2643-
},
2639+
vsim_search_method_params={"K": 3, "EF_RUNTIME": 1},
2640+
yield_score_as="vsim_score",
26442641
)
26452642

26462643
hybrid_query = HybridQuery(search_query, vsim_query)

tests/test_search.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4347,11 +4347,8 @@ def test_hybrid_search_query_with_vsim_score_aliases(self, client):
43474347
vector_field_name="@embedding-hnsw",
43484348
vector_data="abcd1234efgh5678",
43494349
vsim_search_method=VectorSearchMethods.KNN,
4350-
vsim_search_method_params={
4351-
"K": 3,
4352-
"EF_RUNTIME": 1,
4353-
"YIELD_SCORE_AS": "vsim_score",
4354-
},
4350+
vsim_search_method_params={"K": 3, "EF_RUNTIME": 1},
4351+
yield_score_as="vsim_score",
43554352
)
43564353

43574354
hybrid_query = HybridQuery(search_query, vsim_query)
@@ -4433,11 +4430,8 @@ def test_hybrid_search_query_with_combine_all_score_aliases(self, client):
44334430
vector_field_name="@embedding-hnsw",
44344431
vector_data="abcd1234efgh5678",
44354432
vsim_search_method=VectorSearchMethods.KNN,
4436-
vsim_search_method_params={
4437-
"K": 3,
4438-
"EF_RUNTIME": 1,
4439-
"YIELD_SCORE_AS": "vsim_score",
4440-
},
4433+
vsim_search_method_params={"K": 3, "EF_RUNTIME": 1},
4434+
yield_score_as="vsim_score",
44414435
)
44424436

44434437
hybrid_query = HybridQuery(search_query, vsim_query)

0 commit comments

Comments
 (0)