@@ -80,6 +80,8 @@ def _parse_search(self, res, **kwargs):
8080 duration = kwargs ["duration" ],
8181 has_payload = kwargs ["query" ]._with_payloads ,
8282 with_scores = kwargs ["query" ]._with_scores ,
83+ preserve_bytes = kwargs .get ("preserve_bytes" , False ),
84+ binary_fields = kwargs .get ("binary_fields" , None ),
8385 )
8486
8587 def _parse_aggregate (self , res , ** kwargs ):
@@ -96,6 +98,8 @@ def _parse_profile(self, res, **kwargs):
9698 duration = kwargs ["duration" ],
9799 has_payload = query ._with_payloads ,
98100 with_scores = query ._with_scores ,
101+ preserve_bytes = kwargs .get ("preserve_bytes" , False ),
102+ binary_fields = kwargs .get ("binary_fields" , None ),
99103 )
100104
101105 return result , parse_to_dict (res [1 ])
@@ -484,6 +488,8 @@ def search(
484488 self ,
485489 query : Union [str , Query ],
486490 query_params : Union [Dict [str , Union [str , int , float , bytes ]], None ] = None ,
491+ preserve_bytes : bool = False ,
492+ binary_fields : Optional [List [str ]] = None ,
487493 ):
488494 """
489495 Search the index for a given query, and return a result of documents
@@ -493,6 +499,11 @@ def search(
493499 - **query**: the search query. Either a text for simple queries with
494500 default parameters, or a Query object for complex queries.
495501 See RediSearch's documentation on query format
502+ - **preserve_bytes**: If True, preserve binary field values as bytes
503+ instead of converting to UTF-8 strings
504+ - **binary_fields**: List of field names to preserve as bytes when
505+ preserve_bytes=True. If None, all binary fields
506+ are preserved
496507
497508 For more information see `FT.SEARCH <https://valkey.io/commands/ft.search>`_.
498509 """ # noqa
@@ -504,7 +515,8 @@ def search(
504515 return res
505516
506517 return self ._parse_results (
507- SEARCH_CMD , res , query = query , duration = (time .time () - st ) * 1000.0
518+ SEARCH_CMD , res , query = query , duration = (time .time () - st ) * 1000.0 ,
519+ preserve_bytes = preserve_bytes , binary_fields = binary_fields
508520 )
509521
510522 def explain (
@@ -911,6 +923,8 @@ async def search(
911923 self ,
912924 query : Union [str , Query ],
913925 query_params : Dict [str , Union [str , int , float ]] = None ,
926+ preserve_bytes : bool = False ,
927+ binary_fields : Optional [List [str ]] = None ,
914928 ):
915929 """
916930 Search the index for a given query, and return a result of documents
@@ -920,6 +934,11 @@ async def search(
920934 - **query**: the search query. Either a text for simple queries with
921935 default parameters, or a Query object for complex queries.
922936 See RediSearch's documentation on query format
937+ - **preserve_bytes**: If True, preserve binary field values as bytes
938+ instead of converting to UTF-8 strings
939+ - **binary_fields**: List of field names to preserve as bytes when
940+ preserve_bytes=True. If None, all binary fields
941+ are preserved
923942
924943 For more information see `FT.SEARCH <https://valkey.io/commands/ft.search>`_.
925944 """ # noqa
@@ -931,7 +950,8 @@ async def search(
931950 return res
932951
933952 return self ._parse_results (
934- SEARCH_CMD , res , query = query , duration = (time .time () - st ) * 1000.0
953+ SEARCH_CMD , res , query = query , duration = (time .time () - st ) * 1000.0 ,
954+ preserve_bytes = preserve_bytes , binary_fields = binary_fields
935955 )
936956
937957 async def aggregate (
0 commit comments