diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 9971cf103c..cb614d499e 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -76,7 +76,7 @@ jobs: max-parallel: 15 fail-fast: false matrix: - redis-version: ['8.4-RC1-pre.2', '${{ needs.redis_version.outputs.CURRENT }}', '8.0.2' ,'7.4.4', '7.2.9'] + redis-version: ['8.4-GA-pre.2', '${{ needs.redis_version.outputs.CURRENT }}', '8.0.2' ,'7.4.4', '7.2.9'] python-version: ['3.10', '3.14'] parser-backend: ['plain'] event-loop: ['asyncio'] diff --git a/redis/commands/search/hybrid_query.py b/redis/commands/search/hybrid_query.py index 1607f1ded2..3b072082b2 100644 --- a/redis/commands/search/hybrid_query.py +++ b/redis/commands/search/hybrid_query.py @@ -77,6 +77,7 @@ def __init__( vsim_search_method: Optional[VectorSearchMethods] = None, vsim_search_method_params: Optional[Dict[str, Any]] = None, filter: Optional["Filter"] = None, + yield_score_as: Optional[str] = None, ) -> None: """ Create a new hybrid vsim query object. @@ -96,8 +97,7 @@ def __init__( Example for RANGE: {"RADIUS": 10, "EPSILON": 0.1} where RADIUS is mandatory and defines the radius of the search and EPSILON is optional and defines the accuracy of the search. - For both KNN and RANGE, the following parameter is optional: - YIELD_SCORE_AS: The name of the field to yield the calculated score as. + yield_score_as: The name of the field to yield the score as. filter: If defined, a filter will be applied on the vsim query results. """ @@ -108,6 +108,7 @@ def __init__( else: self._vsim_method_params = None self._filter = filter + self._yield_score_as = yield_score_as def vector_field(self) -> str: """Return the vector field name of this query object.""" @@ -149,12 +150,21 @@ def filter(self, flt: "HybridFilter") -> "HybridVsimQuery": self._filter = flt return self + def yield_score_as(self, alias: str) -> "HybridVsimQuery": + """ + Return the score as a field with name `alias`. + """ + self._yield_score_as = alias + return self + def get_args(self) -> List[str]: args = ["VSIM", self._vector_field, self._vector_data] if self._vsim_method_params: args.extend(self._vsim_method_params) if self._filter: args.extend(self._filter.args) + if self._yield_score_as: + args.extend(("YIELD_SCORE_AS", self._yield_score_as)) return args diff --git a/tests/test_asyncio/test_search.py b/tests/test_asyncio/test_search.py index f4b26ae82c..276c8a37c8 100644 --- a/tests/test_asyncio/test_search.py +++ b/tests/test_asyncio/test_search.py @@ -2636,11 +2636,8 @@ async def test_hybrid_search_query_with_combine_all_score_aliases(self, decoded_ vector_field_name="@embedding-hnsw", vector_data="abcd1234efgh5678", vsim_search_method=VectorSearchMethods.KNN, - vsim_search_method_params={ - "K": 3, - "EF_RUNTIME": 1, - "YIELD_SCORE_AS": "vsim_score", - }, + vsim_search_method_params={"K": 3, "EF_RUNTIME": 1}, + yield_score_as="vsim_score", ) hybrid_query = HybridQuery(search_query, vsim_query) diff --git a/tests/test_search.py b/tests/test_search.py index 27f97d8ca8..1b12dc45fc 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -4347,11 +4347,8 @@ def test_hybrid_search_query_with_vsim_score_aliases(self, client): vector_field_name="@embedding-hnsw", vector_data="abcd1234efgh5678", vsim_search_method=VectorSearchMethods.KNN, - vsim_search_method_params={ - "K": 3, - "EF_RUNTIME": 1, - "YIELD_SCORE_AS": "vsim_score", - }, + vsim_search_method_params={"K": 3, "EF_RUNTIME": 1}, + yield_score_as="vsim_score", ) hybrid_query = HybridQuery(search_query, vsim_query) @@ -4433,11 +4430,8 @@ def test_hybrid_search_query_with_combine_all_score_aliases(self, client): vector_field_name="@embedding-hnsw", vector_data="abcd1234efgh5678", vsim_search_method=VectorSearchMethods.KNN, - vsim_search_method_params={ - "K": 3, - "EF_RUNTIME": 1, - "YIELD_SCORE_AS": "vsim_score", - }, + vsim_search_method_params={"K": 3, "EF_RUNTIME": 1}, + yield_score_as="vsim_score", ) hybrid_query = HybridQuery(search_query, vsim_query)