redis 5.1.1__tar.gz → 5.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. {redis-5.1.1/redis.egg-info → redis-5.2.0}/PKG-INFO +1 -1
  2. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/aggregation.py +16 -0
  3. {redis-5.1.1 → redis-5.2.0/redis.egg-info}/PKG-INFO +1 -1
  4. {redis-5.1.1 → redis-5.2.0}/setup.py +1 -1
  5. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_search.py +55 -0
  6. {redis-5.1.1 → redis-5.2.0}/tests/test_search.py +55 -0
  7. {redis-5.1.1 → redis-5.2.0}/INSTALL +0 -0
  8. {redis-5.1.1 → redis-5.2.0}/LICENSE +0 -0
  9. {redis-5.1.1 → redis-5.2.0}/MANIFEST.in +0 -0
  10. {redis-5.1.1 → redis-5.2.0}/README.md +0 -0
  11. {redis-5.1.1 → redis-5.2.0}/redis/__init__.py +0 -0
  12. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/__init__.py +0 -0
  13. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/base.py +0 -0
  14. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/commands.py +0 -0
  15. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/encoders.py +0 -0
  16. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/helpers.py +0 -0
  17. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/hiredis.py +0 -0
  18. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/resp2.py +0 -0
  19. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/resp3.py +0 -0
  20. {redis-5.1.1 → redis-5.2.0}/redis/_parsers/socket.py +0 -0
  21. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/__init__.py +0 -0
  22. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/client.py +0 -0
  23. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/cluster.py +0 -0
  24. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/connection.py +0 -0
  25. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/lock.py +0 -0
  26. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/retry.py +0 -0
  27. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/sentinel.py +0 -0
  28. {redis-5.1.1 → redis-5.2.0}/redis/asyncio/utils.py +0 -0
  29. {redis-5.1.1 → redis-5.2.0}/redis/backoff.py +0 -0
  30. {redis-5.1.1 → redis-5.2.0}/redis/cache.py +0 -0
  31. {redis-5.1.1 → redis-5.2.0}/redis/client.py +0 -0
  32. {redis-5.1.1 → redis-5.2.0}/redis/cluster.py +0 -0
  33. {redis-5.1.1 → redis-5.2.0}/redis/commands/__init__.py +0 -0
  34. {redis-5.1.1 → redis-5.2.0}/redis/commands/bf/__init__.py +0 -0
  35. {redis-5.1.1 → redis-5.2.0}/redis/commands/bf/commands.py +0 -0
  36. {redis-5.1.1 → redis-5.2.0}/redis/commands/bf/info.py +0 -0
  37. {redis-5.1.1 → redis-5.2.0}/redis/commands/cluster.py +0 -0
  38. {redis-5.1.1 → redis-5.2.0}/redis/commands/core.py +0 -0
  39. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/__init__.py +0 -0
  40. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/commands.py +0 -0
  41. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/edge.py +0 -0
  42. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/exceptions.py +0 -0
  43. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/execution_plan.py +0 -0
  44. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/node.py +0 -0
  45. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/path.py +0 -0
  46. {redis-5.1.1 → redis-5.2.0}/redis/commands/graph/query_result.py +0 -0
  47. {redis-5.1.1 → redis-5.2.0}/redis/commands/helpers.py +0 -0
  48. {redis-5.1.1 → redis-5.2.0}/redis/commands/json/__init__.py +0 -0
  49. {redis-5.1.1 → redis-5.2.0}/redis/commands/json/_util.py +0 -0
  50. {redis-5.1.1 → redis-5.2.0}/redis/commands/json/commands.py +0 -0
  51. {redis-5.1.1 → redis-5.2.0}/redis/commands/json/decoders.py +0 -0
  52. {redis-5.1.1 → redis-5.2.0}/redis/commands/json/path.py +0 -0
  53. {redis-5.1.1 → redis-5.2.0}/redis/commands/redismodules.py +0 -0
  54. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/__init__.py +0 -0
  55. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/_util.py +0 -0
  56. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/commands.py +0 -0
  57. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/document.py +0 -0
  58. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/field.py +0 -0
  59. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/indexDefinition.py +0 -0
  60. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/query.py +0 -0
  61. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/querystring.py +0 -0
  62. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/reducers.py +0 -0
  63. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/result.py +0 -0
  64. {redis-5.1.1 → redis-5.2.0}/redis/commands/search/suggestion.py +0 -0
  65. {redis-5.1.1 → redis-5.2.0}/redis/commands/sentinel.py +0 -0
  66. {redis-5.1.1 → redis-5.2.0}/redis/commands/timeseries/__init__.py +0 -0
  67. {redis-5.1.1 → redis-5.2.0}/redis/commands/timeseries/commands.py +0 -0
  68. {redis-5.1.1 → redis-5.2.0}/redis/commands/timeseries/info.py +0 -0
  69. {redis-5.1.1 → redis-5.2.0}/redis/commands/timeseries/utils.py +0 -0
  70. {redis-5.1.1 → redis-5.2.0}/redis/connection.py +0 -0
  71. {redis-5.1.1 → redis-5.2.0}/redis/crc.py +0 -0
  72. {redis-5.1.1 → redis-5.2.0}/redis/credentials.py +0 -0
  73. {redis-5.1.1 → redis-5.2.0}/redis/exceptions.py +0 -0
  74. {redis-5.1.1 → redis-5.2.0}/redis/lock.py +0 -0
  75. {redis-5.1.1 → redis-5.2.0}/redis/ocsp.py +0 -0
  76. {redis-5.1.1 → redis-5.2.0}/redis/retry.py +0 -0
  77. {redis-5.1.1 → redis-5.2.0}/redis/sentinel.py +0 -0
  78. {redis-5.1.1 → redis-5.2.0}/redis/typing.py +0 -0
  79. {redis-5.1.1 → redis-5.2.0}/redis/utils.py +0 -0
  80. {redis-5.1.1 → redis-5.2.0}/redis.egg-info/SOURCES.txt +0 -0
  81. {redis-5.1.1 → redis-5.2.0}/redis.egg-info/dependency_links.txt +0 -0
  82. {redis-5.1.1 → redis-5.2.0}/redis.egg-info/requires.txt +0 -0
  83. {redis-5.1.1 → redis-5.2.0}/redis.egg-info/top_level.txt +0 -0
  84. {redis-5.1.1 → redis-5.2.0}/setup.cfg +0 -0
  85. {redis-5.1.1 → redis-5.2.0}/tests/__init__.py +0 -0
  86. {redis-5.1.1 → redis-5.2.0}/tests/conftest.py +0 -0
  87. {redis-5.1.1 → redis-5.2.0}/tests/mocks.py +0 -0
  88. {redis-5.1.1 → redis-5.2.0}/tests/ssl_utils.py +0 -0
  89. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/__init__.py +0 -0
  90. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/compat.py +0 -0
  91. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/conftest.py +0 -0
  92. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/mocks.py +0 -0
  93. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_bloom.py +0 -0
  94. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_cluster.py +0 -0
  95. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_commands.py +0 -0
  96. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_connect.py +0 -0
  97. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_connection.py +0 -0
  98. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_connection_pool.py +0 -0
  99. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_credentials.py +0 -0
  100. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_cwe_404.py +0 -0
  101. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_encoding.py +0 -0
  102. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_graph.py +0 -0
  103. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_hash.py +0 -0
  104. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_json.py +0 -0
  105. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_lock.py +0 -0
  106. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_monitor.py +0 -0
  107. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_pipeline.py +0 -0
  108. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_pubsub.py +0 -0
  109. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_retry.py +0 -0
  110. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_scripting.py +0 -0
  111. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_sentinel.py +0 -0
  112. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_sentinel_managed_connection.py +0 -0
  113. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/test_timeseries.py +0 -0
  114. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/testdata/jsontestdata.py +0 -0
  115. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/testdata/titles.csv +0 -0
  116. {redis-5.1.1 → redis-5.2.0}/tests/test_asyncio/testdata/will_play_text.csv.bz2 +0 -0
  117. {redis-5.1.1 → redis-5.2.0}/tests/test_bloom.py +0 -0
  118. {redis-5.1.1 → redis-5.2.0}/tests/test_cache.py +0 -0
  119. {redis-5.1.1 → redis-5.2.0}/tests/test_cluster.py +0 -0
  120. {redis-5.1.1 → redis-5.2.0}/tests/test_command_parser.py +0 -0
  121. {redis-5.1.1 → redis-5.2.0}/tests/test_commands.py +0 -0
  122. {redis-5.1.1 → redis-5.2.0}/tests/test_connect.py +0 -0
  123. {redis-5.1.1 → redis-5.2.0}/tests/test_connection.py +0 -0
  124. {redis-5.1.1 → redis-5.2.0}/tests/test_connection_pool.py +0 -0
  125. {redis-5.1.1 → redis-5.2.0}/tests/test_credentials.py +0 -0
  126. {redis-5.1.1 → redis-5.2.0}/tests/test_encoding.py +0 -0
  127. {redis-5.1.1 → redis-5.2.0}/tests/test_function.py +0 -0
  128. {redis-5.1.1 → redis-5.2.0}/tests/test_graph.py +0 -0
  129. {redis-5.1.1 → redis-5.2.0}/tests/test_graph_utils/__init__.py +0 -0
  130. {redis-5.1.1 → redis-5.2.0}/tests/test_graph_utils/test_edge.py +0 -0
  131. {redis-5.1.1 → redis-5.2.0}/tests/test_graph_utils/test_node.py +0 -0
  132. {redis-5.1.1 → redis-5.2.0}/tests/test_graph_utils/test_path.py +0 -0
  133. {redis-5.1.1 → redis-5.2.0}/tests/test_hash.py +0 -0
  134. {redis-5.1.1 → redis-5.2.0}/tests/test_helpers.py +0 -0
  135. {redis-5.1.1 → redis-5.2.0}/tests/test_json.py +0 -0
  136. {redis-5.1.1 → redis-5.2.0}/tests/test_lock.py +0 -0
  137. {redis-5.1.1 → redis-5.2.0}/tests/test_monitor.py +0 -0
  138. {redis-5.1.1 → redis-5.2.0}/tests/test_multiprocessing.py +0 -0
  139. {redis-5.1.1 → redis-5.2.0}/tests/test_parsers/test_helpers.py +0 -0
  140. {redis-5.1.1 → redis-5.2.0}/tests/test_pipeline.py +0 -0
  141. {redis-5.1.1 → redis-5.2.0}/tests/test_pubsub.py +0 -0
  142. {redis-5.1.1 → redis-5.2.0}/tests/test_retry.py +0 -0
  143. {redis-5.1.1 → redis-5.2.0}/tests/test_scripting.py +0 -0
  144. {redis-5.1.1 → redis-5.2.0}/tests/test_sentinel.py +0 -0
  145. {redis-5.1.1 → redis-5.2.0}/tests/test_ssl.py +0 -0
  146. {redis-5.1.1 → redis-5.2.0}/tests/test_timeseries.py +0 -0
  147. {redis-5.1.1 → redis-5.2.0}/tests/test_utils.py +0 -0
  148. {redis-5.1.1 → redis-5.2.0}/tests/testdata/jsontestdata.py +0 -0
  149. {redis-5.1.1 → redis-5.2.0}/tests/testdata/titles.csv +0 -0
  150. {redis-5.1.1 → redis-5.2.0}/tests/testdata/will_play_text.csv.bz2 +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: redis
3
- Version: 5.1.1
3
+ Version: 5.2.0
4
4
  Summary: Python client for Redis database and key-value store
5
5
  Home-page: https://github.com/redis/redis-py
6
6
  Author: Redis Inc.
@@ -112,6 +112,7 @@ class AggregateRequest:
112
112
  self._cursor = []
113
113
  self._dialect = None
114
114
  self._add_scores = False
115
+ self._scorer = "TFIDF"
115
116
 
116
117
  def load(self, *fields: List[str]) -> "AggregateRequest":
117
118
  """
@@ -300,6 +301,17 @@ class AggregateRequest:
300
301
  self._add_scores = True
301
302
  return self
302
303
 
304
+ def scorer(self, scorer: str) -> "AggregateRequest":
305
+ """
306
+ Use a different scoring function to evaluate document relevance.
307
+ Default is `TFIDF`.
308
+
309
+ :param scorer: The scoring function to use
310
+ (e.g. `TFIDF.DOCNORM` or `BM25`)
311
+ """
312
+ self._scorer = scorer
313
+ return self
314
+
303
315
  def verbatim(self) -> "AggregateRequest":
304
316
  self._verbatim = True
305
317
  return self
@@ -323,6 +335,9 @@ class AggregateRequest:
323
335
  if self._verbatim:
324
336
  ret.append("VERBATIM")
325
337
 
338
+ if self._scorer:
339
+ ret.extend(["SCORER", self._scorer])
340
+
326
341
  if self._add_scores:
327
342
  ret.append("ADDSCORES")
328
343
 
@@ -332,6 +347,7 @@ class AggregateRequest:
332
347
  if self._loadall:
333
348
  ret.append("LOAD")
334
349
  ret.append("*")
350
+
335
351
  elif self._loadfields:
336
352
  ret.append("LOAD")
337
353
  ret.append(str(len(self._loadfields)))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: redis
3
- Version: 5.1.1
3
+ Version: 5.2.0
4
4
  Summary: Python client for Redis database and key-value store
5
5
  Home-page: https://github.com/redis/redis-py
6
6
  Author: Redis Inc.
@@ -8,7 +8,7 @@ setup(
8
8
  long_description_content_type="text/markdown",
9
9
  keywords=["Redis", "key-value store", "database"],
10
10
  license="MIT",
11
- version="5.1.1",
11
+ version="5.2.0",
12
12
  packages=find_packages(
13
13
  include=[
14
14
  "redis",
@@ -1556,6 +1556,61 @@ async def test_aggregations_add_scores(decoded_r: redis.Redis):
1556
1556
  assert res.rows[1] == ["__score", "0.2"]
1557
1557
 
1558
1558
 
1559
+ @pytest.mark.redismod
1560
+ @skip_ifmodversion_lt("2.10.05", "search")
1561
+ async def test_aggregations_hybrid_scoring(decoded_r: redis.Redis):
1562
+ assert await decoded_r.ft().create_index(
1563
+ (
1564
+ TextField("name", sortable=True, weight=5.0),
1565
+ TextField("description", sortable=True, weight=5.0),
1566
+ VectorField(
1567
+ "vector",
1568
+ "HNSW",
1569
+ {"TYPE": "FLOAT32", "DIM": 2, "DISTANCE_METRIC": "COSINE"},
1570
+ ),
1571
+ )
1572
+ )
1573
+
1574
+ assert await decoded_r.hset(
1575
+ "doc1",
1576
+ mapping={
1577
+ "name": "cat book",
1578
+ "description": "an animal book about cats",
1579
+ "vector": np.array([0.1, 0.2]).astype(np.float32).tobytes(),
1580
+ },
1581
+ )
1582
+ assert await decoded_r.hset(
1583
+ "doc2",
1584
+ mapping={
1585
+ "name": "dog book",
1586
+ "description": "an animal book about dogs",
1587
+ "vector": np.array([0.2, 0.1]).astype(np.float32).tobytes(),
1588
+ },
1589
+ )
1590
+
1591
+ query_string = "(@description:animal)=>[KNN 3 @vector $vec_param AS dist]"
1592
+ req = (
1593
+ aggregations.AggregateRequest(query_string)
1594
+ .scorer("BM25")
1595
+ .add_scores()
1596
+ .apply(hybrid_score="@__score + @dist")
1597
+ .load("*")
1598
+ .dialect(4)
1599
+ )
1600
+
1601
+ res = await decoded_r.ft().aggregate(
1602
+ req,
1603
+ query_params={"vec_param": np.array([0.11, 0.22]).astype(np.float32).tobytes()},
1604
+ )
1605
+
1606
+ if isinstance(res, dict):
1607
+ assert len(res["results"]) == 2
1608
+ else:
1609
+ assert len(res.rows) == 2
1610
+ for row in res.rows:
1611
+ len(row) == 6
1612
+
1613
+
1559
1614
  @pytest.mark.redismod
1560
1615
  @skip_if_redis_enterprise()
1561
1616
  async def test_search_commands_in_pipeline(decoded_r: redis.Redis):
@@ -1466,6 +1466,61 @@ def test_aggregations_add_scores(client):
1466
1466
  assert res.rows[1] == ["__score", "0.2"]
1467
1467
 
1468
1468
 
1469
+ @pytest.mark.redismod
1470
+ @skip_ifmodversion_lt("2.10.05", "search")
1471
+ async def test_aggregations_hybrid_scoring(client):
1472
+ client.ft().create_index(
1473
+ (
1474
+ TextField("name", sortable=True, weight=5.0),
1475
+ TextField("description", sortable=True, weight=5.0),
1476
+ VectorField(
1477
+ "vector",
1478
+ "HNSW",
1479
+ {"TYPE": "FLOAT32", "DIM": 2, "DISTANCE_METRIC": "COSINE"},
1480
+ ),
1481
+ )
1482
+ )
1483
+
1484
+ client.hset(
1485
+ "doc1",
1486
+ mapping={
1487
+ "name": "cat book",
1488
+ "description": "an animal book about cats",
1489
+ "vector": np.array([0.1, 0.2]).astype(np.float32).tobytes(),
1490
+ },
1491
+ )
1492
+ client.hset(
1493
+ "doc2",
1494
+ mapping={
1495
+ "name": "dog book",
1496
+ "description": "an animal book about dogs",
1497
+ "vector": np.array([0.2, 0.1]).astype(np.float32).tobytes(),
1498
+ },
1499
+ )
1500
+
1501
+ query_string = "(@description:animal)=>[KNN 3 @vector $vec_param AS dist]"
1502
+ req = (
1503
+ aggregations.AggregateRequest(query_string)
1504
+ .scorer("BM25")
1505
+ .add_scores()
1506
+ .apply(hybrid_score="@__score + @dist")
1507
+ .load("*")
1508
+ .dialect(4)
1509
+ )
1510
+
1511
+ res = client.ft().aggregate(
1512
+ req,
1513
+ query_params={"vec_param": np.array([0.11, 0.21]).astype(np.float32).tobytes()},
1514
+ )
1515
+
1516
+ if isinstance(res, dict):
1517
+ assert len(res["results"]) == 2
1518
+ else:
1519
+ assert len(res.rows) == 2
1520
+ for row in res.rows:
1521
+ len(row) == 6
1522
+
1523
+
1469
1524
  @pytest.mark.redismod
1470
1525
  @skip_ifmodversion_lt("2.0.0", "search")
1471
1526
  def test_index_definition(client):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes