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

Method test_scores

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

TextFieldClass · 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
with_scoresMethod · 0.80
ftMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected