coredis 4.24.0__py3-none-any.whl → 5.0.0rc1__py3-none-any.whl

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.

Potentially problematic release.


This version of coredis might be problematic. Click here for more details.

Files changed (77) hide show
  1. coredis/__init__.py +1 -3
  2. coredis/_packer.py +10 -10
  3. coredis/_protocols.py +23 -32
  4. coredis/_py_311_typing.py +20 -0
  5. coredis/_py_312_typing.py +17 -0
  6. coredis/_utils.py +49 -51
  7. coredis/_version.py +3 -3
  8. coredis/cache.py +57 -82
  9. coredis/client/__init__.py +1 -2
  10. coredis/client/basic.py +129 -56
  11. coredis/client/cluster.py +147 -70
  12. coredis/commands/__init__.py +27 -7
  13. coredis/commands/_key_spec.py +11 -10
  14. coredis/commands/_utils.py +1 -1
  15. coredis/commands/_validators.py +30 -20
  16. coredis/commands/_wrappers.py +19 -99
  17. coredis/commands/bitfield.py +10 -2
  18. coredis/commands/constants.py +20 -3
  19. coredis/commands/core.py +1627 -1246
  20. coredis/commands/function.py +21 -19
  21. coredis/commands/monitor.py +0 -71
  22. coredis/commands/pubsub.py +7 -142
  23. coredis/commands/request.py +108 -0
  24. coredis/commands/script.py +9 -9
  25. coredis/commands/sentinel.py +60 -49
  26. coredis/connection.py +14 -15
  27. coredis/exceptions.py +2 -2
  28. coredis/experimental/__init__.py +0 -4
  29. coredis/globals.py +3 -0
  30. coredis/modules/autocomplete.py +28 -30
  31. coredis/modules/base.py +15 -31
  32. coredis/modules/filters.py +269 -245
  33. coredis/modules/graph.py +61 -62
  34. coredis/modules/json.py +172 -140
  35. coredis/modules/response/_callbacks/autocomplete.py +5 -4
  36. coredis/modules/response/_callbacks/graph.py +34 -29
  37. coredis/modules/response/_callbacks/json.py +5 -3
  38. coredis/modules/response/_callbacks/search.py +49 -53
  39. coredis/modules/response/_callbacks/timeseries.py +18 -30
  40. coredis/modules/response/types.py +1 -5
  41. coredis/modules/search.py +186 -169
  42. coredis/modules/timeseries.py +184 -164
  43. coredis/parser.py +6 -19
  44. coredis/pipeline.py +391 -422
  45. coredis/pool/basic.py +7 -7
  46. coredis/pool/cluster.py +3 -3
  47. coredis/pool/nodemanager.py +10 -3
  48. coredis/response/_callbacks/__init__.py +76 -57
  49. coredis/response/_callbacks/acl.py +0 -3
  50. coredis/response/_callbacks/cluster.py +25 -16
  51. coredis/response/_callbacks/command.py +8 -6
  52. coredis/response/_callbacks/connection.py +4 -3
  53. coredis/response/_callbacks/geo.py +17 -13
  54. coredis/response/_callbacks/hash.py +13 -11
  55. coredis/response/_callbacks/keys.py +9 -5
  56. coredis/response/_callbacks/module.py +2 -3
  57. coredis/response/_callbacks/script.py +6 -8
  58. coredis/response/_callbacks/sentinel.py +21 -17
  59. coredis/response/_callbacks/server.py +36 -14
  60. coredis/response/_callbacks/sets.py +3 -4
  61. coredis/response/_callbacks/sorted_set.py +27 -24
  62. coredis/response/_callbacks/streams.py +22 -13
  63. coredis/response/_callbacks/strings.py +7 -6
  64. coredis/response/_callbacks/vector_sets.py +126 -0
  65. coredis/response/types.py +13 -4
  66. coredis/sentinel.py +1 -1
  67. coredis/stream.py +4 -3
  68. coredis/tokens.py +343 -16
  69. coredis/typing.py +432 -79
  70. {coredis-4.24.0.dist-info → coredis-5.0.0rc1.dist-info}/METADATA +4 -5
  71. coredis-5.0.0rc1.dist-info/RECORD +95 -0
  72. coredis/client/keydb.py +0 -336
  73. coredis/pipeline.pyi +0 -2103
  74. coredis-4.24.0.dist-info/RECORD +0 -93
  75. {coredis-4.24.0.dist-info → coredis-5.0.0rc1.dist-info}/WHEEL +0 -0
  76. {coredis-4.24.0.dist-info → coredis-5.0.0rc1.dist-info}/licenses/LICENSE +0 -0
  77. {coredis-4.24.0.dist-info → coredis-5.0.0rc1.dist-info}/top_level.txt +0 -0
coredis/modules/search.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import dataclasses
4
4
  import itertools
5
+ from collections import OrderedDict
5
6
  from datetime import timedelta
6
7
 
7
8
  from deprecated.sphinx import versionadded
@@ -9,6 +10,7 @@ from deprecated.sphinx import versionadded
9
10
  from ..commands._utils import normalized_milliseconds, normalized_seconds
10
11
  from ..commands._wrappers import ClusterCommandConfig
11
12
  from ..commands.constants import CommandGroup, CommandName, NodeFlag
13
+ from ..commands.request import CommandRequest
12
14
  from ..response._callbacks import (
13
15
  AnyStrCallback,
14
16
  ClusterEnsureConsistent,
@@ -37,7 +39,6 @@ from .response._callbacks.search import (
37
39
  SearchConfigCallback,
38
40
  SearchResultCallback,
39
41
  SpellCheckCallback,
40
- SpellCheckResult,
41
42
  )
42
43
  from .response.types import SearchAggregationResult, SearchResult
43
44
 
@@ -204,7 +205,7 @@ class Group:
204
205
  bies: list[StringT] = list(self.by)
205
206
  args.extend([len(bies), *bies])
206
207
  for reducer in self.reducers or []:
207
- args.append(PrefixToken.REDUCE)
208
+ args.append(PureToken.REDUCE)
208
209
  args.extend(reducer.args)
209
210
 
210
211
  return args
@@ -261,7 +262,7 @@ class Search(ModuleGroup[AnyStr]):
261
262
  version_introduced="1.0.0",
262
263
  group=COMMAND_GROUP,
263
264
  )
264
- async def create(
265
+ def create(
265
266
  self,
266
267
  index: KeyT,
267
268
  schema: Parameters[Field],
@@ -282,7 +283,7 @@ class Search(ModuleGroup[AnyStr]):
282
283
  nofreqs: bool | None = None,
283
284
  stopwords: Parameters[StringT] | None = None,
284
285
  skipinitialscan: bool | None = None,
285
- ) -> bool:
286
+ ) -> CommandRequest[bool]:
286
287
  """
287
288
  Creates an index with the given spec
288
289
 
@@ -307,50 +308,50 @@ class Search(ModuleGroup[AnyStr]):
307
308
  :param stopwords: A list of stopwords to ignore.
308
309
  :param skipinitialscan: If ``True``, the initial scan of the index will be skipped.
309
310
  """
310
- pieces: CommandArgList = [index]
311
+ command_arguments: CommandArgList = [index]
311
312
  if on:
312
- pieces.extend([PrefixToken.ON, on])
313
+ command_arguments.extend([PrefixToken.ON, on])
313
314
 
314
315
  if prefixes:
315
316
  _prefixes: list[StringT] = list(prefixes)
316
- pieces.extend([PrefixToken.PREFIX, len(_prefixes), *_prefixes])
317
+ command_arguments.extend([PrefixToken.PREFIX, len(_prefixes), *_prefixes])
317
318
  if filter_expression:
318
- pieces.extend([PrefixToken.FILTER, filter_expression])
319
+ command_arguments.extend([PrefixToken.FILTER, filter_expression])
319
320
  if language:
320
- pieces.extend([PrefixToken.LANGUAGE, language])
321
+ command_arguments.extend([PrefixToken.LANGUAGE, language])
321
322
  if language_field:
322
- pieces.extend([PrefixToken.LANGUAGE_FIELD, language_field])
323
+ command_arguments.extend([PrefixToken.LANGUAGE_FIELD, language_field])
323
324
  if score:
324
- pieces.extend([PrefixToken.SCORE, score])
325
+ command_arguments.extend([PrefixToken.SCORE, score])
325
326
  if score_field:
326
- pieces.extend([PrefixToken.SCORE_FIELD, score_field])
327
+ command_arguments.extend([PrefixToken.SCORE_FIELD, score_field])
327
328
  if payload_field:
328
- pieces.extend([PrefixToken.PAYLOAD_FIELD, payload_field])
329
+ command_arguments.extend([PrefixToken.PAYLOAD_FIELD, payload_field])
329
330
  if maxtextfields:
330
- pieces.append(PureToken.MAXTEXTFIELDS)
331
+ command_arguments.append(PureToken.MAXTEXTFIELDS)
331
332
  if temporary:
332
- pieces.extend([PrefixToken.TEMPORARY, normalized_seconds(temporary)])
333
+ command_arguments.extend([PrefixToken.TEMPORARY, normalized_seconds(temporary)])
333
334
  if nooffsets:
334
- pieces.append(PureToken.NOOFFSETS)
335
+ command_arguments.append(PureToken.NOOFFSETS)
335
336
  if nohl:
336
- pieces.append(PureToken.NOHL)
337
+ command_arguments.append(PureToken.NOHL)
337
338
  if nofields:
338
- pieces.append(PureToken.NOFIELDS)
339
+ command_arguments.append(PureToken.NOFIELDS)
339
340
  if nofreqs:
340
- pieces.append(PureToken.NOFREQS)
341
+ command_arguments.append(PureToken.NOFREQS)
341
342
  if stopwords:
342
343
  _stop: list[StringT] = list(stopwords)
343
- pieces.extend([PrefixToken.STOPWORDS, len(_stop), *_stop])
344
+ command_arguments.extend([PrefixToken.STOPWORDS, len(_stop), *_stop])
344
345
  if skipinitialscan:
345
- pieces.append(PureToken.SKIPINITIALSCAN)
346
+ command_arguments.append(PureToken.SKIPINITIALSCAN)
346
347
 
347
348
  field_args: CommandArgList = [PureToken.SCHEMA]
348
349
  for field in schema:
349
350
  field_args.extend(field.args)
350
- pieces.extend(field_args)
351
+ command_arguments.extend(field_args)
351
352
 
352
- return await self.execute_module_command(
353
- CommandName.FT_CREATE, *pieces, callback=SimpleStringCallback()
353
+ return self.client.create_request(
354
+ CommandName.FT_CREATE, *command_arguments, callback=SimpleStringCallback()
354
355
  )
355
356
 
356
357
  @module_command(
@@ -359,13 +360,13 @@ class Search(ModuleGroup[AnyStr]):
359
360
  version_introduced="1.0.0",
360
361
  group=COMMAND_GROUP,
361
362
  )
362
- async def info(self, index: KeyT) -> dict[AnyStr, ResponseType]:
363
+ def info(self, index: KeyT) -> CommandRequest[dict[AnyStr, ResponseType]]:
363
364
  """
364
365
  Returns information and statistics on the index
365
366
 
366
367
  :param index: The name of the index.
367
368
  """
368
- return await self.execute_module_command(
369
+ return self.client.create_request(
369
370
  CommandName.FT_INFO,
370
371
  index,
371
372
  callback=DictCallback[AnyStr, ResponseType](
@@ -386,7 +387,9 @@ class Search(ModuleGroup[AnyStr]):
386
387
  group=COMMAND_GROUP,
387
388
  arguments={"dialect": {"version_introduced": "2.4.3"}},
388
389
  )
389
- async def explain(self, index: KeyT, query: StringT, dialect: int | None = None) -> AnyStr:
390
+ def explain(
391
+ self, index: KeyT, query: StringT, dialect: int | None = None
392
+ ) -> CommandRequest[AnyStr]:
390
393
  """
391
394
  Returns the execution plan for a complex query
392
395
 
@@ -394,11 +397,13 @@ class Search(ModuleGroup[AnyStr]):
394
397
  :param query: The query to explain.
395
398
  :param dialect: Query dialect to use.
396
399
  """
397
- pieces: CommandArgList = [index, query]
400
+ command_arguments: CommandArgList = [index, query]
398
401
  if dialect:
399
- pieces.extend([PrefixToken.DIALECT, dialect])
400
- return await self.execute_module_command(
401
- CommandName.FT_EXPLAIN, *pieces, callback=AnyStrCallback[AnyStr]()
402
+ command_arguments.extend([PrefixToken.DIALECT, dialect])
403
+ return self.client.create_request(
404
+ CommandName.FT_EXPLAIN,
405
+ *command_arguments,
406
+ callback=AnyStrCallback[AnyStr](),
402
407
  )
403
408
 
404
409
  @module_command(
@@ -407,12 +412,12 @@ class Search(ModuleGroup[AnyStr]):
407
412
  version_introduced="1.0.0",
408
413
  group=COMMAND_GROUP,
409
414
  )
410
- async def alter(
415
+ def alter(
411
416
  self,
412
417
  index: KeyT,
413
418
  field: Field,
414
419
  skipinitialscan: bool | None = None,
415
- ) -> bool:
420
+ ) -> CommandRequest[bool]:
416
421
  """
417
422
  Adds a new field to the index
418
423
 
@@ -421,13 +426,13 @@ class Search(ModuleGroup[AnyStr]):
421
426
  :param skipinitialscan: If ``True``, skip the initial scan and indexing.
422
427
 
423
428
  """
424
- pieces: CommandArgList = [index]
429
+ command_arguments: CommandArgList = [index]
425
430
  if skipinitialscan:
426
- pieces.append(PureToken.SKIPINITIALSCAN)
427
- pieces.extend([PureToken.SCHEMA, PureToken.ADD, *field.args])
431
+ command_arguments.append(PureToken.SKIPINITIALSCAN)
432
+ command_arguments.extend([PureToken.SCHEMA, PureToken.ADD, *field.args])
428
433
 
429
- return await self.execute_module_command(
430
- CommandName.FT_ALTER, *pieces, callback=SimpleStringCallback()
434
+ return self.client.create_request(
435
+ CommandName.FT_ALTER, *command_arguments, callback=SimpleStringCallback()
431
436
  )
432
437
 
433
438
  @module_command(
@@ -436,19 +441,21 @@ class Search(ModuleGroup[AnyStr]):
436
441
  version_introduced="2.0.0",
437
442
  group=COMMAND_GROUP,
438
443
  )
439
- async def dropindex(self, index: KeyT, delete_docs: bool | None = None) -> bool:
444
+ def dropindex(self, index: KeyT, delete_docs: bool | None = None) -> CommandRequest[bool]:
440
445
  """
441
446
  Deletes the index
442
447
 
443
448
  :param index: The name of the index to delete.
444
449
  :param delete_docs: If ``True``, delete the documents associated with the index.
445
450
  """
446
- pieces: CommandArgList = [index]
451
+ command_arguments: CommandArgList = [index]
447
452
  if delete_docs:
448
- pieces.append(PureToken.DELETE_DOCS)
453
+ command_arguments.append(PureToken.DELETE_DOCS)
449
454
 
450
- return await self.execute_module_command(
451
- CommandName.FT_DROPINDEX, *pieces, callback=SimpleStringCallback()
455
+ return self.client.create_request(
456
+ CommandName.FT_DROPINDEX,
457
+ *command_arguments,
458
+ callback=SimpleStringCallback(),
452
459
  )
453
460
 
454
461
  @module_command(
@@ -457,7 +464,7 @@ class Search(ModuleGroup[AnyStr]):
457
464
  version_introduced="1.0.0",
458
465
  group=COMMAND_GROUP,
459
466
  )
460
- async def aliasadd(self, alias: StringT, index: KeyT) -> bool:
467
+ def aliasadd(self, alias: StringT, index: KeyT) -> CommandRequest[bool]:
461
468
  """
462
469
  Adds an alias to the index
463
470
 
@@ -465,7 +472,7 @@ class Search(ModuleGroup[AnyStr]):
465
472
  :param index: The index to which the alias will be added.
466
473
  """
467
474
 
468
- return await self.execute_module_command(
475
+ return self.client.create_request(
469
476
  CommandName.FT_ALIASADD, alias, index, callback=SimpleStringCallback()
470
477
  )
471
478
 
@@ -475,7 +482,7 @@ class Search(ModuleGroup[AnyStr]):
475
482
  version_introduced="1.0.0",
476
483
  group=COMMAND_GROUP,
477
484
  )
478
- async def aliasupdate(self, alias: StringT, index: KeyT) -> bool:
485
+ def aliasupdate(self, alias: StringT, index: KeyT) -> CommandRequest[bool]:
479
486
  """
480
487
  Adds or updates an alias to the index
481
488
 
@@ -483,7 +490,7 @@ class Search(ModuleGroup[AnyStr]):
483
490
  :param index: The index to which the alias will be added.
484
491
  """
485
492
 
486
- return await self.execute_module_command(
493
+ return self.client.create_request(
487
494
  CommandName.FT_ALIASUPDATE, alias, index, callback=SimpleStringCallback()
488
495
  )
489
496
 
@@ -493,14 +500,14 @@ class Search(ModuleGroup[AnyStr]):
493
500
  version_introduced="1.0.0",
494
501
  group=COMMAND_GROUP,
495
502
  )
496
- async def aliasdel(self, alias: StringT) -> bool:
503
+ def aliasdel(self, alias: StringT) -> CommandRequest[bool]:
497
504
  """
498
505
  Deletes an alias from the index
499
506
 
500
507
  :param alias: The index alias to be removed.
501
508
  """
502
509
 
503
- return await self.execute_module_command(
510
+ return self.client.create_request(
504
511
  CommandName.FT_ALIASDEL, alias, callback=SimpleStringCallback()
505
512
  )
506
513
 
@@ -510,7 +517,7 @@ class Search(ModuleGroup[AnyStr]):
510
517
  version_introduced="1.0.0",
511
518
  group=COMMAND_GROUP,
512
519
  )
513
- async def tagvals(self, index: KeyT, field_name: StringT) -> set[AnyStr]:
520
+ def tagvals(self, index: KeyT, field_name: StringT) -> CommandRequest[set[AnyStr]]:
514
521
  """
515
522
  Returns the distinct tags indexed in a Tag field
516
523
 
@@ -518,7 +525,7 @@ class Search(ModuleGroup[AnyStr]):
518
525
  :param field_name: Name of a Tag field defined in the schema.
519
526
  """
520
527
 
521
- return await self.execute_module_command(
528
+ return self.client.create_request(
522
529
  CommandName.FT_TAGVALS, index, field_name, callback=SetCallback[AnyStr]()
523
530
  )
524
531
 
@@ -528,13 +535,13 @@ class Search(ModuleGroup[AnyStr]):
528
535
  version_introduced="1.2.0",
529
536
  group=COMMAND_GROUP,
530
537
  )
531
- async def synupdate(
538
+ def synupdate(
532
539
  self,
533
540
  index: KeyT,
534
541
  synonym_group: StringT,
535
542
  terms: Parameters[StringT],
536
543
  skipinitialscan: bool | None = None,
537
- ) -> bool:
544
+ ) -> CommandRequest[bool]:
538
545
  """
539
546
  Creates or updates a synonym group with additional terms
540
547
 
@@ -545,12 +552,14 @@ class Search(ModuleGroup[AnyStr]):
545
552
  update will be affected.
546
553
 
547
554
  """
548
- pieces: CommandArgList = [index, synonym_group]
555
+ command_arguments: CommandArgList = [index, synonym_group]
549
556
  if skipinitialscan:
550
- pieces.append(PureToken.SKIPINITIALSCAN)
551
- pieces.extend(terms)
552
- return await self.execute_module_command(
553
- CommandName.FT_SYNUPDATE, *pieces, callback=SimpleStringCallback()
557
+ command_arguments.append(PureToken.SKIPINITIALSCAN)
558
+ command_arguments.extend(terms)
559
+ return self.client.create_request(
560
+ CommandName.FT_SYNUPDATE,
561
+ *command_arguments,
562
+ callback=SimpleStringCallback(),
554
563
  )
555
564
 
556
565
  @module_command(
@@ -559,15 +568,17 @@ class Search(ModuleGroup[AnyStr]):
559
568
  version_introduced="1.2.0",
560
569
  group=COMMAND_GROUP,
561
570
  )
562
- async def syndump(self, index: KeyT) -> dict[AnyStr, list[AnyStr]]:
571
+ def syndump(self, index: KeyT) -> CommandRequest[dict[AnyStr, list[AnyStr]]]:
563
572
  """
564
573
  Dumps the contents of a synonym group
565
574
 
566
575
  :param index: The name of the index.
567
576
  """
568
577
 
569
- return await self.execute_module_command(
570
- CommandName.FT_SYNDUMP, index, callback=DictCallback[AnyStr, list[AnyStr]]()
578
+ return self.client.create_request(
579
+ CommandName.FT_SYNDUMP,
580
+ index,
581
+ callback=DictCallback[AnyStr, list[AnyStr]](),
571
582
  )
572
583
 
573
584
  @module_command(
@@ -577,7 +588,7 @@ class Search(ModuleGroup[AnyStr]):
577
588
  group=COMMAND_GROUP,
578
589
  arguments={"dialect": {"version_introduced": "2.4.3"}},
579
590
  )
580
- async def spellcheck(
591
+ def spellcheck(
581
592
  self,
582
593
  index: KeyT,
583
594
  query: StringT,
@@ -585,7 +596,7 @@ class Search(ModuleGroup[AnyStr]):
585
596
  include: StringT | None = None,
586
597
  exclude: StringT | None = None,
587
598
  dialect: int | None = None,
588
- ) -> SpellCheckResult:
599
+ ) -> CommandRequest[dict[AnyStr, OrderedDict[AnyStr, float]]]:
589
600
  """
590
601
  Performs spelling correction on a query, returning suggestions for misspelled terms
591
602
 
@@ -596,17 +607,19 @@ class Search(ModuleGroup[AnyStr]):
596
607
  :param exclude: Specifies an exclusion of a custom dictionary
597
608
  :param dialect: The query dialect to use.
598
609
  """
599
- pieces: CommandArgList = [index, query]
610
+ command_arguments: CommandArgList = [index, query]
600
611
  if distance:
601
- pieces.extend([PrefixToken.DISTANCE, distance])
612
+ command_arguments.extend([PrefixToken.DISTANCE, distance])
602
613
  if exclude:
603
- pieces.extend([PrefixToken.TERMS, PureToken.EXCLUDE, exclude])
614
+ command_arguments.extend([PrefixToken.TERMS, PureToken.EXCLUDE, exclude])
604
615
  if include:
605
- pieces.extend([PrefixToken.TERMS, PureToken.INCLUDE, include])
616
+ command_arguments.extend([PrefixToken.TERMS, PureToken.INCLUDE, include])
606
617
  if dialect:
607
- pieces.extend([PrefixToken.DIALECT, dialect])
608
- return await self.execute_module_command(
609
- CommandName.FT_SPELLCHECK, *pieces, callback=SpellCheckCallback()
618
+ command_arguments.extend([PrefixToken.DIALECT, dialect])
619
+ return self.client.create_request(
620
+ CommandName.FT_SPELLCHECK,
621
+ *command_arguments,
622
+ callback=SpellCheckCallback[AnyStr](),
610
623
  )
611
624
 
612
625
  @module_command(
@@ -615,21 +628,21 @@ class Search(ModuleGroup[AnyStr]):
615
628
  version_introduced="1.4.0",
616
629
  group=COMMAND_GROUP,
617
630
  )
618
- async def dictadd(
631
+ def dictadd(
619
632
  self,
620
633
  name: StringT,
621
634
  terms: Parameters[StringT],
622
- ) -> int:
635
+ ) -> CommandRequest[int]:
623
636
  """
624
637
  Adds terms to a dictionary
625
638
 
626
639
  :param name: The name of the dictionary.
627
640
  :param terms: The terms to add to the dictionary.
628
641
  """
629
- pieces: CommandArgList = [name, *terms]
642
+ command_arguments: CommandArgList = [name, *terms]
630
643
 
631
- return await self.execute_module_command(
632
- CommandName.FT_DICTADD, *pieces, callback=IntCallback()
644
+ return self.client.create_request(
645
+ CommandName.FT_DICTADD, *command_arguments, callback=IntCallback()
633
646
  )
634
647
 
635
648
  @module_command(
@@ -638,21 +651,21 @@ class Search(ModuleGroup[AnyStr]):
638
651
  version_introduced="1.4.0",
639
652
  group=COMMAND_GROUP,
640
653
  )
641
- async def dictdel(
654
+ def dictdel(
642
655
  self,
643
656
  name: StringT,
644
657
  terms: Parameters[StringT],
645
- ) -> int:
658
+ ) -> CommandRequest[int]:
646
659
  """
647
660
  Deletes terms from a dictionary
648
661
 
649
662
  :param name: The name of the dictionary.
650
663
  :param terms: The terms to delete from the dictionary.
651
664
  """
652
- pieces: CommandArgList = [name, *terms]
665
+ command_arguments: CommandArgList = [name, *terms]
653
666
 
654
- return await self.execute_module_command(
655
- CommandName.FT_DICTDEL, *pieces, callback=IntCallback()
667
+ return self.client.create_request(
668
+ CommandName.FT_DICTDEL, *command_arguments, callback=IntCallback()
656
669
  )
657
670
 
658
671
  @module_command(
@@ -661,14 +674,14 @@ class Search(ModuleGroup[AnyStr]):
661
674
  version_introduced="1.4.0",
662
675
  group=COMMAND_GROUP,
663
676
  )
664
- async def dictdump(self, name: StringT) -> set[AnyStr]:
677
+ def dictdump(self, name: StringT) -> CommandRequest[set[AnyStr]]:
665
678
  """
666
679
  Dumps all terms in the given dictionary
667
680
 
668
681
  :param name: The name of the dictionary to dump.
669
682
  """
670
683
 
671
- return await self.execute_module_command(
684
+ return self.client.create_request(
672
685
  CommandName.FT_DICTDUMP, name, callback=SetCallback[AnyStr]()
673
686
  )
674
687
 
@@ -682,30 +695,29 @@ class Search(ModuleGroup[AnyStr]):
682
695
  combine=ClusterMergeSets[AnyStr](),
683
696
  ),
684
697
  )
685
- async def list(self) -> set[AnyStr]:
698
+ def list(self) -> CommandRequest[set[AnyStr]]:
686
699
  """
687
700
  Returns a list of all existing indexes
688
701
  """
689
- return await self.execute_module_command(
690
- CommandName.FT__LIST, callback=SetCallback[AnyStr]()
691
- )
702
+ return self.client.create_request(CommandName.FT__LIST, callback=SetCallback[AnyStr]())
692
703
 
693
704
  @module_command(
694
705
  CommandName.FT_CONFIG_SET,
695
706
  module=MODULE,
696
707
  version_introduced="1.0.0",
708
+ version_deprecated="8.0.0",
697
709
  group=COMMAND_GROUP,
698
710
  cluster=ClusterCommandConfig(
699
711
  route=NodeFlag.PRIMARIES,
700
712
  combine=ClusterEnsureConsistent[bool](),
701
713
  ),
702
714
  )
703
- async def config_set(self, option: StringT, value: ValueT) -> bool:
715
+ def config_set(self, option: StringT, value: ValueT) -> CommandRequest[bool]:
704
716
  """
705
717
  Sets runtime configuration options
706
718
  """
707
719
 
708
- return await self.execute_module_command(
720
+ return self.client.create_request(
709
721
  CommandName.FT_CONFIG_SET, option, value, callback=SimpleStringCallback()
710
722
  )
711
723
 
@@ -713,17 +725,18 @@ class Search(ModuleGroup[AnyStr]):
713
725
  CommandName.FT_CONFIG_GET,
714
726
  module=MODULE,
715
727
  version_introduced="1.0.0",
728
+ version_deprecated="8.0.0",
716
729
  group=COMMAND_GROUP,
717
730
  cluster=ClusterCommandConfig(
718
731
  route=NodeFlag.RANDOM,
719
732
  ),
720
733
  )
721
- async def config_get(self, option: StringT) -> dict[AnyStr, ResponsePrimitive]:
734
+ def config_get(self, option: StringT) -> CommandRequest[dict[AnyStr, ResponsePrimitive]]:
722
735
  """
723
736
  Retrieves runtime configuration options
724
737
  """
725
738
 
726
- return await self.execute_module_command(
739
+ return self.client.create_request(
727
740
  CommandName.FT_CONFIG_GET,
728
741
  option,
729
742
  callback=SearchConfigCallback[AnyStr](),
@@ -736,7 +749,7 @@ class Search(ModuleGroup[AnyStr]):
736
749
  group=COMMAND_GROUP,
737
750
  arguments={"dialect": {"version_introduced": "2.4.3"}},
738
751
  )
739
- async def search(
752
+ def search(
740
753
  self,
741
754
  index: KeyT,
742
755
  query: StringT,
@@ -783,7 +796,7 @@ class Search(ModuleGroup[AnyStr]):
783
796
  limit: int | None = None,
784
797
  parameters: Mapping[StringT, ValueT] | None = None,
785
798
  dialect: int | None = None,
786
- ) -> SearchResult[AnyStr]:
799
+ ) -> CommandRequest[SearchResult[AnyStr]]:
787
800
  """
788
801
  Searches the index with a textual query, returning either documents or just ids
789
802
 
@@ -832,25 +845,27 @@ class Search(ModuleGroup[AnyStr]):
832
845
  :param dialect: The query dialect to use.
833
846
 
834
847
  """
835
- pieces: CommandArgList = [index, query]
848
+ command_arguments: CommandArgList = [index, query]
836
849
  if nocontent:
837
- pieces.append(PureToken.NOCONTENT)
850
+ command_arguments.append(PureToken.NOCONTENT)
838
851
  if verbatim:
839
- pieces.append(PureToken.VERBATIM)
852
+ command_arguments.append(PureToken.VERBATIM)
840
853
  if nostopwords:
841
- pieces.append(PureToken.NOSTOPWORDS)
854
+ command_arguments.append(PureToken.NOSTOPWORDS)
842
855
  if withscores:
843
- pieces.append(PureToken.WITHSCORES)
856
+ command_arguments.append(PureToken.WITHSCORES)
844
857
  if withpayloads:
845
- pieces.append(PureToken.WITHPAYLOADS)
858
+ command_arguments.append(PureToken.WITHPAYLOADS)
846
859
  if withsortkeys:
847
- pieces.append(PureToken.WITHSORTKEYS)
860
+ command_arguments.append(PureToken.WITHSORTKEYS)
848
861
  if numeric_filters:
849
862
  for field, numeric_filter in numeric_filters.items():
850
- pieces.extend([PrefixToken.FILTER, field, numeric_filter[0], numeric_filter[1]])
863
+ command_arguments.extend(
864
+ [PrefixToken.FILTER, field, numeric_filter[0], numeric_filter[1]]
865
+ )
851
866
  if geo_filters:
852
867
  for field, gfilter in geo_filters.items():
853
- pieces.extend(
868
+ command_arguments.extend(
854
869
  [
855
870
  PrefixToken.GEOFILTER,
856
871
  field,
@@ -862,72 +877,73 @@ class Search(ModuleGroup[AnyStr]):
862
877
  )
863
878
  if in_keys:
864
879
  _in_keys: list[StringT] = list(in_keys)
865
- pieces.extend([PrefixToken.INKEYS, len(_in_keys), *_in_keys])
880
+ command_arguments.extend([PrefixToken.INKEYS, len(_in_keys), *_in_keys])
866
881
  if in_fields:
867
882
  _in_fields: list[StringT] = list(in_fields)
868
- pieces.extend([PrefixToken.INFIELDS, len(_in_fields), *_in_fields])
883
+ command_arguments.extend([PrefixToken.INFIELDS, len(_in_fields), *_in_fields])
869
884
  if returns:
870
885
  return_items: CommandArgList = []
871
886
  for identifier, property in returns.items():
872
887
  return_items.append(identifier)
873
888
  if property:
874
889
  return_items.extend([PrefixToken.AS, property])
875
- pieces.extend([PrefixToken.RETURN, len(return_items), *return_items])
890
+ command_arguments.extend([PrefixToken.RETURN, len(return_items), *return_items])
876
891
  if sortby:
877
- pieces.extend([PrefixToken.SORTBY, sortby])
892
+ command_arguments.extend([PrefixToken.SORTBY, sortby])
878
893
  if sort_order:
879
- pieces.append(sort_order)
894
+ command_arguments.append(sort_order)
880
895
  if summarize_fields or summarize_frags or summarize_length or summarize_separator:
881
- pieces.append(PureToken.SUMMARIZE)
896
+ command_arguments.append(PureToken.SUMMARIZE)
882
897
  if summarize_fields:
883
898
  _fields: list[StringT] = list(summarize_fields)
884
- pieces.extend([PrefixToken.FIELDS, len(_fields), *_fields])
899
+ command_arguments.extend([PrefixToken.FIELDS, len(_fields), *_fields])
885
900
  if summarize_frags:
886
- pieces.extend([PrefixToken.FRAGS, summarize_frags])
901
+ command_arguments.extend([PrefixToken.FRAGS, summarize_frags])
887
902
  if summarize_length:
888
- pieces.extend([PrefixToken.LEN, summarize_length])
903
+ command_arguments.extend([PrefixToken.LEN, summarize_length])
889
904
  if summarize_separator:
890
- pieces.extend([PrefixToken.SEPARATOR, summarize_separator])
905
+ command_arguments.extend([PrefixToken.SEPARATOR, summarize_separator])
891
906
  if highlight_fields or highlight_tags:
892
- pieces.append(PureToken.HIGHLIGHT)
907
+ command_arguments.append(PureToken.HIGHLIGHT)
893
908
  if highlight_fields:
894
909
  _fields = list(highlight_fields)
895
- pieces.extend([PrefixToken.FIELDS, len(_fields), *_fields])
910
+ command_arguments.extend([PrefixToken.FIELDS, len(_fields), *_fields])
896
911
  if highlight_tags:
897
- pieces.extend([PureToken.TAGS, highlight_tags[0], highlight_tags[1]])
912
+ command_arguments.extend([PureToken.TAGS, highlight_tags[0], highlight_tags[1]])
898
913
  if slop is not None:
899
- pieces.extend([PrefixToken.SLOP, slop])
914
+ command_arguments.extend([PrefixToken.SLOP, slop])
900
915
  if timeout:
901
- pieces.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
916
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
902
917
  if inorder:
903
- pieces.append(PureToken.INORDER)
918
+ command_arguments.append(PureToken.INORDER)
904
919
  if language:
905
- pieces.extend([PrefixToken.LANGUAGE, language])
920
+ command_arguments.extend([PrefixToken.LANGUAGE, language])
906
921
  if expander: # noqa
907
- pieces.extend([PrefixToken.EXPANDER, expander])
922
+ command_arguments.extend([PrefixToken.EXPANDER, expander])
908
923
  if scorer: # noqa
909
- pieces.extend([PrefixToken.SCORER, scorer])
924
+ command_arguments.extend([PrefixToken.SCORER, scorer])
910
925
  if explainscore:
911
- pieces.append(PureToken.EXPLAINSCORE)
926
+ command_arguments.append(PureToken.EXPLAINSCORE)
912
927
  if payload:
913
- pieces.extend([PrefixToken.PAYLOAD, payload])
928
+ command_arguments.extend([PrefixToken.PAYLOAD, payload])
914
929
  if limit is not None:
915
- pieces.extend([PrefixToken.LIMIT, offset or 0, limit])
930
+ command_arguments.extend([PrefixToken.LIMIT, offset or 0, limit])
916
931
  if parameters:
917
932
  _parameters: list[ValueT] = list(itertools.chain(*parameters.items()))
918
- pieces.extend([PureToken.PARAMS, len(_parameters), *_parameters])
933
+ command_arguments.extend([PureToken.PARAMS, len(_parameters), *_parameters])
919
934
  if dialect:
920
- pieces.extend([PrefixToken.DIALECT, dialect])
935
+ command_arguments.extend([PrefixToken.DIALECT, dialect])
921
936
 
922
- return await self.execute_module_command(
937
+ return self.client.create_request(
923
938
  CommandName.FT_SEARCH,
924
- *pieces,
925
- callback=SearchResultCallback[AnyStr](),
926
- withscores=withscores,
927
- withpayloads=withpayloads,
928
- withsortkeys=withsortkeys,
929
- explainscore=explainscore,
930
- nocontent=nocontent,
939
+ *command_arguments,
940
+ callback=SearchResultCallback[AnyStr](
941
+ withscores=withscores,
942
+ withpayloads=withpayloads,
943
+ withsortkeys=withsortkeys,
944
+ explainscore=explainscore,
945
+ nocontent=nocontent,
946
+ ),
931
947
  )
932
948
 
933
949
  @module_command(
@@ -937,7 +953,7 @@ class Search(ModuleGroup[AnyStr]):
937
953
  group=COMMAND_GROUP,
938
954
  arguments={"dialect": {"version_introduced": "2.4.3"}},
939
955
  )
940
- async def aggregate(
956
+ def aggregate(
941
957
  self,
942
958
  index: KeyT,
943
959
  query: StringT,
@@ -955,7 +971,7 @@ class Search(ModuleGroup[AnyStr]):
955
971
  cursor_maxidle: int | timedelta | None = None,
956
972
  parameters: Mapping[StringT, StringT] | None = None,
957
973
  dialect: int | None = None,
958
- ) -> SearchAggregationResult[AnyStr]:
974
+ ) -> CommandRequest[SearchAggregationResult[AnyStr]]:
959
975
  """
960
976
  Perform aggregate transformations on search results from a Redis index.
961
977
 
@@ -978,15 +994,15 @@ class Search(ModuleGroup[AnyStr]):
978
994
  :return: Aggregated search results from the Redis index.
979
995
 
980
996
  """
981
- pieces: CommandArgList = [index, query]
997
+ command_arguments: CommandArgList = [index, query]
982
998
  if verbatim:
983
- pieces.append(PureToken.VERBATIM)
999
+ command_arguments.append(PureToken.VERBATIM)
984
1000
  if timeout:
985
- pieces.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
1001
+ command_arguments.extend([PrefixToken.TIMEOUT, normalized_milliseconds(timeout)])
986
1002
  if load:
987
- pieces.append(PrefixToken.LOAD)
1003
+ command_arguments.append(PrefixToken.LOAD)
988
1004
  if isinstance(load, (bytes, str)):
989
- pieces.append(load)
1005
+ command_arguments.append(load)
990
1006
  else:
991
1007
  _load_fields: list[StringT] = []
992
1008
  for field in load:
@@ -995,40 +1011,40 @@ class Search(ModuleGroup[AnyStr]):
995
1011
  else:
996
1012
  _load_fields.extend([field[0], PrefixToken.AS, field[1]])
997
1013
 
998
- pieces.extend([len(_load_fields), *_load_fields])
1014
+ command_arguments.extend([len(_load_fields), *_load_fields])
999
1015
 
1000
1016
  if transforms:
1001
1017
  for step in transforms:
1002
- pieces.extend(step.args)
1018
+ command_arguments.extend(step.args)
1003
1019
 
1004
1020
  if sortby:
1005
- pieces.append(PrefixToken.SORTBY)
1006
- pieces.append(len(sortby) * 2)
1021
+ command_arguments.append(PrefixToken.SORTBY)
1022
+ command_arguments.append(len(sortby) * 2)
1007
1023
  for field, order in sortby.items():
1008
- pieces.extend([field, order])
1024
+ command_arguments.extend([field, order])
1009
1025
  if sortby_max:
1010
- pieces.extend([PrefixToken.MAX, sortby_max])
1026
+ command_arguments.extend([PrefixToken.MAX, sortby_max])
1011
1027
 
1012
1028
  if limit is not None:
1013
- pieces.extend([PrefixToken.LIMIT, offset or 0, limit])
1029
+ command_arguments.extend([PrefixToken.LIMIT, offset or 0, limit])
1014
1030
 
1015
1031
  if with_cursor:
1016
- pieces.append(PureToken.WITHCURSOR)
1032
+ command_arguments.append(PureToken.WITHCURSOR)
1017
1033
  if cursor_read_size:
1018
- pieces.extend([PrefixToken.COUNT, cursor_read_size])
1034
+ command_arguments.extend([PrefixToken.COUNT, cursor_read_size])
1019
1035
  if cursor_maxidle:
1020
- pieces.extend([PrefixToken.MAXIDLE, normalized_milliseconds(cursor_maxidle)])
1036
+ command_arguments.extend(
1037
+ [PrefixToken.MAXIDLE, normalized_milliseconds(cursor_maxidle)]
1038
+ )
1021
1039
  if parameters:
1022
1040
  _parameters: list[StringT] = list(itertools.chain(*parameters.items()))
1023
- pieces.extend([PureToken.PARAMS, len(_parameters), *_parameters])
1041
+ command_arguments.extend([PureToken.PARAMS, len(_parameters), *_parameters])
1024
1042
  if dialect:
1025
- pieces.extend([PrefixToken.DIALECT, dialect])
1026
- return await self.execute_module_command(
1043
+ command_arguments.extend([PrefixToken.DIALECT, dialect])
1044
+ return self.client.create_request(
1027
1045
  CommandName.FT_AGGREGATE,
1028
- *pieces,
1029
- callback=AggregationResultCallback[AnyStr](),
1030
- with_cursor=with_cursor,
1031
- dialect=dialect,
1046
+ *command_arguments,
1047
+ callback=AggregationResultCallback[AnyStr](with_cursor=with_cursor, dialect=dialect),
1032
1048
  )
1033
1049
 
1034
1050
  @module_command(
@@ -1037,21 +1053,20 @@ class Search(ModuleGroup[AnyStr]):
1037
1053
  version_introduced="1.1.0",
1038
1054
  group=COMMAND_GROUP,
1039
1055
  )
1040
- async def cursor_read(
1056
+ def cursor_read(
1041
1057
  self, index: KeyT, cursor_id: int, count: int | None = None
1042
- ) -> SearchAggregationResult[AnyStr]:
1058
+ ) -> CommandRequest[SearchAggregationResult[AnyStr]]:
1043
1059
  """
1044
1060
  Reads from a cursor
1045
1061
  """
1046
- pieces: CommandArgList = [index, cursor_id]
1062
+ command_arguments: CommandArgList = [index, cursor_id]
1047
1063
  if count:
1048
- pieces.extend([PrefixToken.COUNT, count])
1064
+ command_arguments.extend([PrefixToken.COUNT, count])
1049
1065
 
1050
- return await self.execute_module_command(
1066
+ return self.client.create_request(
1051
1067
  CommandName.FT_CURSOR_READ,
1052
- *pieces,
1053
- callback=AggregationResultCallback[AnyStr](),
1054
- with_cursor=True,
1068
+ *command_arguments,
1069
+ callback=AggregationResultCallback[AnyStr](with_cursor=True),
1055
1070
  )
1056
1071
 
1057
1072
  @module_command(
@@ -1060,13 +1075,15 @@ class Search(ModuleGroup[AnyStr]):
1060
1075
  version_introduced="1.1.0",
1061
1076
  group=COMMAND_GROUP,
1062
1077
  )
1063
- async def cursor_del(self, index: KeyT, cursor_id: int) -> bool:
1078
+ def cursor_del(self, index: KeyT, cursor_id: int) -> CommandRequest[bool]:
1064
1079
  """
1065
1080
  Deletes a cursor
1066
1081
 
1067
1082
  """
1068
- pieces: CommandArgList = [index, cursor_id]
1083
+ command_arguments: CommandArgList = [index, cursor_id]
1069
1084
 
1070
- return await self.execute_module_command(
1071
- CommandName.FT_CURSOR_DEL, *pieces, callback=SimpleStringCallback()
1085
+ return self.client.create_request(
1086
+ CommandName.FT_CURSOR_DEL,
1087
+ *command_arguments,
1088
+ callback=SimpleStringCallback(),
1072
1089
  )