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

Method test_scores

tests/test_asyncio/test_search.py:383–400  ·  view source on GitHub ↗
(self, decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

381 @pytest.mark.onlynoncluster
382 @skip_if_server_version_gte("7.9.0")
383 async def test_scores(self, decoded_r: redis.Redis):
384 await decoded_r.ft().create_index((TextField("txt"),))
385
386 await decoded_r.hset("doc1", mapping={"txt": "foo baz"})
387 await decoded_r.hset("doc2", mapping={"txt": "foo bar"})
388
389 q = Query("foo ~bar").with_scores()
390 res = await decoded_r.ft().search(q)
391 if expects_resp2_shape(decoded_r) or expects_unified_shape(decoded_r):
392 assert 2 == res.total
393 assert "doc2" == res.docs[0].id
394 assert 3.0 == res.docs[0].score
395 assert "doc1" == res.docs[1].id
396 elif expects_resp3_shape(decoded_r):
397 assert 2 == res["total_results"]
398 assert "doc2" == res["results"][0]["id"]
399 assert 3.0 == res["results"][0]["score"]
400 assert "doc1" == res["results"][1]["id"]
401
402 @pytest.mark.redismod
403 @pytest.mark.onlynoncluster

Callers

nothing calls this directly

Calls 10

TextFieldClass · 0.90
QueryClass · 0.90
expects_resp2_shapeFunction · 0.90
expects_unified_shapeFunction · 0.90
expects_resp3_shapeFunction · 0.90
create_indexMethod · 0.80
hsetMethod · 0.80
with_scoresMethod · 0.80
ftMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected