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

Method test_synupdate

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

Source from the content-addressed store, hash-verified

1376
1377 @pytest.mark.redismod
1378 def test_synupdate(self, client):
1379 definition = IndexDefinition(index_type=IndexType.HASH)
1380 client.ft().create_index(
1381 (TextField("title"), TextField("body")), definition=definition
1382 )
1383
1384 client.ft().synupdate("id1", True, "boy", "child", "offspring")
1385 client.hset("doc1", mapping={"title": "he is a baby", "body": "this is a test"})
1386
1387 client.ft().synupdate("id1", True, "baby")
1388 client.hset(
1389 "doc2", mapping={"title": "he is another baby", "body": "another test"}
1390 )
1391
1392 res = client.ft().search(Query("child").expander("SYNONYM"))
1393 if expects_resp2_shape(client) or expects_unified_shape(client):
1394 assert res.docs[0].id == "doc2"
1395 assert res.docs[0].title == "he is another baby"
1396 assert res.docs[0].body == "another test"
1397 elif expects_resp3_shape(client):
1398 assert res["results"][0]["id"] == "doc2"
1399 assert (
1400 res["results"][0]["extra_attributes"]["title"] == "he is another baby"
1401 )
1402 assert res["results"][0]["extra_attributes"]["body"] == "another test"
1403
1404 @pytest.mark.redismod
1405 def test_syndump(self, client):

Callers

nothing calls this directly

Calls 12

IndexDefinitionClass · 0.90
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
synupdateMethod · 0.80
hsetMethod · 0.80
expanderMethod · 0.80
ftMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected