MCPcopy
hub / github.com/redis/redis-py / test_profile_query_params

Method test_profile_query_params

tests/test_search.py:2791–2819  ·  view source on GitHub ↗
(self, client)

Source from the content-addressed store, hash-verified

2789 @skip_if_server_version_gte("7.9.0")
2790 @skip_if_server_version_lt("6.3.0")
2791 def test_profile_query_params(self, client):
2792 client.ft().create_index(
2793 (
2794 VectorField(
2795 "v", "HNSW", {"TYPE": "FLOAT32", "DIM": 2, "DISTANCE_METRIC": "L2"}
2796 ),
2797 )
2798 )
2799 client.hset("a", "v", "aaaaaaaa")
2800 client.hset("b", "v", "aaaabaaa")
2801 client.hset("c", "v", "aaaaabaa")
2802 query = "*=>[KNN 2 @v $vec]"
2803 q = Query(query).return_field("__v_score").sort_by("__v_score", True)
2804 if expects_resp2_shape(client) or expects_unified_shape(client):
2805 res, det = client.ft().profile(q, query_params={"vec": "aaaaaaaa"})
2806 det = det.info
2807 assert det[4][1][5] == 2.0
2808 assert det[4][1][1] == "VECTOR"
2809 assert res.total == 2
2810 assert "a" == res.docs[0].id
2811 assert "0" == res.docs[0].__getattribute__("__v_score")
2812 elif expects_resp3_shape(client):
2813 res = client.ft().profile(q, query_params={"vec": "aaaaaaaa"})
2814 res = res.info
2815 assert res["profile"]["Iterators profile"][0]["Counter"] == 2
2816 assert res["profile"]["Iterators profile"][0]["Type"] == "VECTOR"
2817 assert res["total_results"] == 2
2818 assert "a" == res["results"][0]["id"]
2819 assert "0" == res["results"][0]["extra_attributes"]["__v_score"]
2820
2821
2822class TestDifferentFieldTypesSearch(SearchTestsBase):

Callers

nothing calls this directly

Calls 11

VectorFieldClass · 0.90
QueryClass · 0.90
expects_resp2_shapeFunction · 0.85
expects_unified_shapeFunction · 0.85
expects_resp3_shapeFunction · 0.85
create_indexMethod · 0.80
hsetMethod · 0.80
return_fieldMethod · 0.80
profileMethod · 0.80
ftMethod · 0.45
sort_byMethod · 0.45

Tested by

no test coverage detected