
    ng\j%                       S SK r S SKrS SKJrJrJrJrJr  S SKJ	r	  S SK
JrJr  S SKJrJrJrJr  S SKJrJr  S SKJrJrJrJrJr  SS	KJrJr  S
SKJrJ r J!r!  S
SK"J#r#  S
SK$J%r%  S
SK&J'r'  S
SK(J)r)  S
SK*J+r+  S
SK,J-r-  S
SK.J/r/  Sr0Sr1Sr2Sr3Sr4Sr5Sr6Sr7Sr8Sr9Sr:Sr;Sr<S r=S!r>S"r?S#r@S$rAS%rBS&rCS'rDS(rES)rFS*rGS+rHS,rIS-rJS.rKS/rLS0rMS1rNS2rOS3rPS4rQS5rRS6rSS7rTS8rUS9rVS:rWS;rXS<rY " S= S>5      rZ " S? S@\Z5      r[g)A    N)AnyDictListOptionalUnion)pairs_to_dict)NEVER_DECODEPipeline)CombineResultsMethodHybridCursorQueryHybridPostProcessingConfigHybridQuery)HybridCursorResultHybridResult)check_protocol_versiondecode_field_valuedeprecated_functionexperimental_methodstr_if_bytes   )get_legacy_responsesget_protocol_version   )AggregateRequestAggregateResultCursor)Document)Field)IndexDefinition)ProfileInformation)Query)Result)SuggestionParserNUMERICz	FT.CREATEzFT.ALTERz	FT.SEARCHzFT.ADDz
FT.ADDHASHzFT.DROPINDEXz
FT.EXPLAINzFT.EXPLAINCLIzFT.DELzFT.AGGREGATEz
FT.PROFILEz	FT.CURSORzFT.SPELLCHECKz
FT.DICTADDz
FT.DICTDELzFT.DICTDUMPzFT.MGETz	FT.CONFIGz
FT.TAGVALSzFT.ALIASADDzFT.ALIASUPDATEzFT.ALIASDELzFT.INFOz	FT.SUGADDz	FT.SUGDELz	FT.SUGLENz	FT.SUGGETzFT.SYNUPDATEz
FT.SYNDUMPz	FT.HYBRID	NOOFFSETSNOFIELDSNOHLNOFREQSMAXTEXTFIELDS	TEMPORARY	STOPWORDSSKIPINITIALSCAN
WITHSCORESFUZZYWITHPAYLOADSc                      \ rS rSrSr\" \\\\	\
15      rS rS r\SS j5       r\S 5       rS rS	 rS
 rS rS rS rS rS rS rS r\" 1 Sk5      r\S 5       rS rS rS rS r S r!S r"S r#S r$S r%\S 5       r&\S 5       r'S r(S  r)S! r*S" r+S# r,\SS$ j5       r-\S% 5       r.S& r/\S' 5       r0S( r1S) r2S* r3S+ r4SS, jr5         SS-\6\7   S.\8S/\8S0\9\6\:      S1\9\;   S2\8S3\8S4\84S5 jjr<S-\=\7\6\7   4   4S6 jr>SS7\84S8 jjr?        SS9 jr@ SS: jrA\B" S;S<S=9       SS>\:S?\8S@\CSA\9\8   SB\8SC\8SD\9\:   SE\8S-\6\:   4SF jj5       rD\B" S;S<S=9SSG j5       rE\B" S;SHS=9SSI j5       rFSSJ\9\G\:\H4      4SK jjrI\B" S;SHS=9SL 5       rJSM rKSN\9\G\:\=\:\L\C\M4   4      4SO jrNSN\9\G\:\=\:\L\C\M4   4      4SP jrO SSQ\=\:\P4   SN\=\G\:\=\:\L\C\M4   4   S4   4SR jjrQ\R" 5            SSQ\SSS\9\T   ST\9\U   SU\9\G\:\=\:\L\C\M4   4      SV\9\L   SW\9\V   SX\=\W\X\Y4   4SY jj5       rZ SSQ\=\:\P4   SN\9\G\:\=\:\L\C\M4   4      4SZ jjr[SQ\=\:\P4   4S[ jr\ SSQ\=\]\^4   SN\9\G\:\=\:\L\C\M4   4      4S\ jjr_S]\6SQ\=\]\^4   S^\84S_ jr`  SSQ\=\P\]4   S`\8SN\9\G\:\=\:\L\C\M4   4      SX\=\a\=\b\c4   \d4   \d4   4Sa jjreSSb jrfSc\:Sd\6\:   4Se jrgSc\:Sd\6\:   4Sf jrhSc\:4Sg jri\B" ShSiS=9Sj\:Sk\:SX\84Sl j5       rj\B" ShSmS=9Sj\:SX\:4Sn j5       rkSo\:4Sp jrlSq\:4Sr jrmSq\:4Ss jrnSq\:4St jroSu rpSv\:SX\L4Sw jrqSv\:Sx\:SX\L4Sy jrr    SSv\:Sz\:S{\8S|\LS}\8S~\8SX\6\s   4S jjrtSS\:S\8Sd\6\:   4S jjruS rvSrwg)SearchCommandsR   zSearch commands.c                    [         U R                  [        U R                  [        U R
                  [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  0U l        [        U R"                  0U l        [         U R&                  [        U R(                  [        U R*                  [        U R,                  [        U R.                  [        U R0                  [        U R2                  [        U R4                  0U l        [        U R8                  [        U R:                  0U l        [         U R>                  [        U R                  [        U R@                  [        U R                  [        U RB                  [        U R                  [        U RD                  [        U RF                  0U l$        [K        U R6                  5      U l&        U RN                  U RL                  [         '   U RP                  U RL                  [        '   U RR                  U RL                  [        '   U RT                  U RL                  [        '   g)zBuild the per-protocol module callback maps.

Called from ``Search.__init__``, ``Pipeline.__init__`` and
``AsyncPipeline.__init__`` so the mapping lives in a single place
rather than being duplicated across all three classes.
N)+INFO_CMD_parse_info
SEARCH_CMD_parse_search
HYBRID_CMD_parse_hybrid_searchAGGREGATE_CMD_parse_aggregatePROFILE_CMD_parse_profileSPELLCHECK_CMD_parse_spellcheck
CONFIG_CMD_parse_config_getSYNDUMP_CMD_parse_syndump_RESP2_MODULE_CALLBACKS!_parse_hybrid_search_resp3_native_RESP3_MODULE_CALLBACKS_parse_info_resp3_to_legacy_parse_search_resp3_parse_hybrid_search_resp3_parse_aggregate_resp3_parse_profile_resp3_parse_spellcheck_resp3!_parse_config_get_resp3_to_legacy_parse_syndump_resp3'_RESP3_TO_RESP2_LEGACY_MODULE_CALLBACKS&_pipeline_parse_search_resp3_to_legacy-_pipeline_parse_hybrid_search_resp3_to_legacy)_RESP3_TO_RESP2_LEGACY_PIPELINE_CALLBACKS_parse_info_unified_parse_hybrid_search_unified_parse_profile_unified_parse_config_get_unified_parse_syndump_unified_RESP2_UNIFIED_MODULE_CALLBACKSdict_RESP3_UNIFIED_MODULE_CALLBACKS_parse_info_resp3_parse_config_get_resp3_parse_profile_resp3_unified"_parse_hybrid_search_resp3_unified)selfs    Y/home/edenadmin/noVNC/venv/lib/python3.13/site-packages/redis/commands/search/commands.py_init_module_callbacks%SearchCommands._init_module_callbacks^   s    d&&**11400,,D22..,,	(
$  >>(
$ d66007746622D88>>22	8
4 CCJJ:
6 d..**9940044D226644	0
, 04880
, :>9O9O,,X6;?;W;W,,Z8-- 	,,[9 33 	,,Z8    c                 >   XR                   ;   a  SU;  a  U$ [        U R                  5      n[        U R                  5      nU(       a  US;   a1  U[        :X  a  [        U5      $ U R                  R                  U5      nO[        US5      (       a  U R                  R                  U5      nOdU R                  R                  U5      nOH[        US5      (       a  U R                  R                  U5      nOU R                  R                  U5      nUc  U$ U" U40 UD6$ )Nquery)   3rf   )_QUERY_REQUIRED_CMDSr   clientr   r<   r    rF   getr   rO   rD   rZ   rX   )r_   cmdreskwargsprotocollegacycbs          r`   _parse_resultsSearchCommands._parse_results   s    +++v0EJ'4%dkk28#+%-c221155c:'!44AAEEcJ1155c:%h2299==cB99==cB:J#   rc   Nc                     [        U [        5      (       d  U$ U R                  XR                  UR                  5       U5      5      $ N)
isinstancerY   rj   encode)mappingkeydefaults      r`   
_resp3_getSearchCommands._resp3_get   s4    '4((N{{3CJJL' BCCrc   c                     [        U [        5      (       d  U $ / nU R                  5        H0  u  p#UR                  [	        U5      5        UR                  U5        M2     U$ rt   )ru   rY   itemsappendr   )rw   flatrx   values       r`   _flatten_resp3_mapping%SearchCommands._flatten_resp3_mapping   sO    '4((N!--/JCKKS)*KK * rc   c           
      J   UR                  S5      nUb  [        U[        5      (       d  U$ U R                  USS5      /nU R                  US/ 5       H  nUR	                  U R                  US5      5        UR
                  (       a!  UR	                  U R                  US5      5        UR                  (       a!  UR	                  U R                  US5      5        UR                  (       a  M  UR	                  U R                  U R                  US0 5      5      5        M     U$ )	zDConvert RESP3 FT.SEARCH pipeline output to raw RESP2 pipeline shape.re   total_resultsr   resultsidscorepayloadextra_attributes)	rj   ru   rY   rz   r~   _with_scores_with_payloads_no_contentr   )r_   rl   rm   re   outputitems         r`   rP   5SearchCommands._pipeline_parse_search_resp3_to_legacy   s    

7#=
3 5 5J//#:;OOCB7DMM$//$56!!doodG<=##doodI>?$$$//.@"E 8 rc   c                    [        U[        5      (       d  U$ UR                  5        VVs0 s H  u  p4[        U5      U_M     nnnSU;   a$  SUR	                  S5      SUR	                  S5      /$ UR	                  S/ 5       Vs/ s H+  n[        U[        5      (       a  U R                  U5      OUPM-     nnSUR	                  SS5      SUSUR	                  S/ 5      SUR	                  SS5      /$ s  snnf s  snf )	zDConvert RESP3 FT.HYBRID pipeline output to raw RESP2 pipeline shape.cursorSEARCHVSIMr   r   r   warningsexecution_time)ru   rY   r}   r   rj   r   )r_   rl   rm   rx   r   r   r   s          r`   rQ   <SearchCommands._pipeline_parse_hybrid_search_resp3_to_legacy   s    #t$$J:=))+F+JC|C %'+Fvcggh/II 	2.
. 2<D$1G1GD''-TQ. 	 

 GGOQ'GGJ#GG$a(	
 		
 G
s   C22C8c                 J    [        [        U5      n[        [        X35      5      $ rt   )mapr   rY   zip)r_   rl   rm   its       r`   r5   SearchCommands._parse_info  s    s#CK  rc   c           	          [        UUS   R                  (       + US   US   R                  US   R                  US   R                  S9$ )Nre   duration)r   has_payloadwith_scoresfield_encodings)r"   r   r   r   _return_fields_decode_asr_   rl   rm   s      r`   r7   SearchCommands._parse_search  sQ    w+++J'w66w44"7ODD
 	
rc   c           	         [        USS9nSU;   a"  [        [        US   5      [        US   5      S9$ / nUS    H  n[        USS9nUR                  U5        M      [	        [        US   5      UUS	   [        US
   5      S9$ )NTdecode_keysr   r   r   search_cursor_idvsim_cursor_idr   r   r   r   r   r   r   r   )r   r   intr~   r   float)r_   rl   rm   res_dictr   res_item	item_dicts          r`   r9   #SearchCommands._parse_hybrid_search  s     $7v%!$Xh%7!8"8F#34 
 )+ !+H%hDAINN9% , h78j) *:!;<	
 	
rc   c                 2    U R                  XS   US   5      $ )Nre   
has_cursor)_get_aggregate_resultr   s      r`   r;   SearchCommands._parse_aggregate&  s    ))#g|@TUUrc   c                    US   n[        U[        5      (       a   U R                  US   X3R                  5      nO6[	        US   UR
                  (       + US   UR                  UR                  S9nU[        US   5      4$ )Nre   r   r   r   r   r   r   )	ru   r   r   _cursorr"   r   r   r   r    )r_   rl   rm   re   results        r`   r=   SearchCommands._parse_profile)  s    we-..//A}}MFA%%%
+!00!..F )#a&111rc   c                    0 nUS:X  a  U$ U Ho  n[        U[        5      (       a  US:X  a  M   [        U5      S:w  a  M1  US   (       d  M=  US   S   (       d  ML  US    Vs/ s H  oUS   US   S.PM     snX4S   '   Mq     U$ s  snf )Nr   rf   r   r   r   
suggestion)ru   r   len)r_   rl   rm   corrections_correction_items         r`   r?    SearchCommands._parse_spellcheck8  s    !8K+s++q0@;1$q>q>!$$ JUUV+IW(%(;+KA'5 < 	+s    Bc                 P    U(       a  U Vs0 s H  o3S   US   _M     sn$ 0 $ s  snf Nr   r    r_   rl   rm   kvss       r`   rA    SearchCommands._parse_config_get]  s+    25#.#3AA#.=2=.s   #c                 j    [        S[        U5      S5       Vs0 s H  o1U   XS-      _M     sn$ s  snf Nr   r   r   )ranger   )r_   rl   rm   is       r`   rC   SearchCommands._parse_syndump`  s6    ,1!SXq,AB,AqAE
",ABBBs   0>   typeWEIGHTPHONETIC	SEPARATOR	attribute
identifierc                    0 n/ n[         R                  nSnU[        U 5      :  ac  [        X   5      nXS;   a*  US-   [        U 5      :  a  [        XS-      5      X'   US-  nOUR	                  U5        US-  nU[        U 5      :  a  Mc  X!S'   U$ )a  Convert a RESP2 flat attribute list into a RESP3-style dict.

RESP2 format: ``[identifier, name, attribute, alias, type, TEXT,
WEIGHT, 1, SORTABLE, NOSTEM]``.
RESP3 format: ``{"identifier": name, "attribute": alias, "type":
"TEXT", "WEIGHT": "1", "flags": ["SORTABLE", "NOSTEM"]}``.
r   r   r   flags)r1   _INFO_ATTR_PAIR_KEYSr   r   r~   )	attr_listr   r   	pair_keysr   rx   s         r`   _normalize_info_attribute(SearchCommands._normalize_info_attributek  s     "77	#i. y|,CAEC	N$:*9U+;<QS!Q #i.   wrc   c                    [        [        U5      n[        [        X35      5      nSU;   aW  [	        US   [
        5      (       a?  US    Vs/ s H+  n[	        U[
        5      (       a  U R                  U5      OUPM-     snUS'   U$ s  snf )zrParse FT.INFO into the unified shape with ``attributes`` as a
list of dicts so RESP2 output matches RESP3 output.

attributes)r   r   rY   r   ru   listr   )r_   rl   rm   r   infoattrs         r`   rS   "SearchCommands._parse_info_unified  s     s#CK 4JtL/A4$H$H !.".D 9C48N8N..t4TXX."D 	"s   
2Bc                    [        USS9nSU;   a"  [        [        US   5      [        US   5      S9$ U R                  " S0 UD6n/ nUS    HQ  n[        USS9nUR	                  UR                  5        VV	s0 s H  u  pXR                  XU5      _M     sn	n5        MS     [        [        US   5      UUS	   [        US
   5      S9$ s  sn	nf )NTr   r   r   r   r   r   r   r   r   r   r   )	r   r   r   _hybrid_field_encodingsr~   r}   _decode_hybrid_field_valuer   r   )
r_   rl   rm   r   r   r   r   r   rx   r   s
             r`   rT   +SearchCommands._parse_hybrid_search_unified  s     $7v%!$Xh%7!8"8F#34 
 66@@(* +H%hDAINN '0oo&7&7
 88_UU&7 , h78j) *:!;<	
 	
s   7Cc                    US   n[        U[        5      (       a   U R                  US   X3R                  5      nO6[	        US   UR
                  (       + US   UR                  UR                  S9nUS   n[        U[        5      (       a/  U(       a(  [        US   [        [        45      (       a
  [        USS9nU[        U5      4$ )zwParse FT.PROFILE into ``(result, ProfileInformation)`` with
the profile_data normalised to a dict on >= 7.9.0 servers.
re   r   r   r   r   Tr   )ru   r   r   r   r"   r   r   r   r   strbytesr   r    )r_   rl   rm   re   r   profile_datas         r`   rU   %SearchCommands._parse_profile_unified  s     we-..//A}}MFA%%%
+!00!..F 1v |T**<?S%L99(4HL),777rc   c                 v    U(       d  0 $ U Vs0 s H  n[        US   5      [        US   5      _M      sn$ s  snf r   )r   r   s       r`   rV   (SearchCommands._parse_config_get_unified  s9    IFIJcsSV$l3q6&::cJJJs   %6c                 &   U(       d  0 $ [        S[        U5      S5       VVs0 s HZ  n[        X   5      [        XS-      [        5      (       a!  XS-       Vs/ s H  n[        U5      PM     snO[        XS-      5      _M\     snn$ s  snf s  snnf r   )r   r   r   ru   r   )r_   rl   rm   r   ss        r`   rW   %SearchCommands._parse_syndump_unified  s    I
 1c#h*	
 +  #!e*d++ =@AJ"GJq<?J"Gca%j)* +	
 	
"G
s   5BB-BBc           
          UR                  S5      n[        R                  " UUR                  SS5      [        USS5      [        USS5      S9$ )	z4Parse RESP3 FT.SEARCH response into a Result object.re   r   r   r   Fr   N)r   r   r   )rj   r"   
from_resp3getattr)r_   rl   rm   re   s       r`   rH   "SearchCommands._parse_search_resp3  sM    

7#  ZZ
A.~u=#E+EtL	
 	
rc   c                    UR                  S5      nUR                  SS5      nSnU(       a1  [        U[        5      (       a  US   n[        U5      S:  a  US   OSnOUnUc  0 nUR	                  5        VVs0 s H  u  px[        U5      U_M     nnnUR                  S/ 5       V	s/ s H  n	[        U	5      PM     n
n	UR                  SS5      n/ nUR                  S	/ 5       H  nUR	                  5        VVs0 s H  u  px[        U5      U_M     nnnUR                  S
0 5      n/ nUR	                  5        H'  u  pxUR                  U5        UR                  U5        M)     UR                  U5        M     SnU(       a)  [        U[        5      (       a	  XSl        UnO[        U5      n[        UUSXS9$ s  snnf s  sn	f s  snnf )zAParse RESP3 FT.AGGREGATE response into an AggregateResult object.re   r   Fr   r   Nwarningr   r   r   )totalr   )
rj   ru   r   r   r}   r   r~   r   cidr   )r_   rl   rm   re   r   	cursor_iddatakvwr   r   rowsresult_itemextra_attrsr   r   s                    r`   rJ   %SearchCommands._parse_aggregate_resp3  s   

7#ZZe4
 	*S$//q6D"%c(Q,AAID<D 04zz|<|tqQ"|<-1XXi-DE-DLO-DE!,88Ir2K:E:K:K:MN:M$!<?A-:MKN%//*<bAK D#))+AA , KK 3 %((%		*tVTRR3 =E
 Os   8F7'F=:Gc                 t   UR                  5        VVs0 s H  u  p4[        U5      U_M     nnnSU;   a"  [        [        US   5      [        US   5      S9$ / nUR	                  S/ 5       Hq  n[        U[        5      (       a@  UR                  UR                  5        VVs0 s H  u  p4[        U5      U_M     snn5        MX  UR                  [        USS95        Ms     [        [        UR	                  SS	5      5      UUR	                  S
/ 5      [        UR	                  SS	5      5      S9$ s  snnf s  snnf )a  Parse RESP3 FT.HYBRID response into HybridResult/HybridCursorResult.

Top-level keys are normalised to strings.  Values are preserved
as delivered by the wire (bytes when ``NEVER_DECODE`` is set,
strings otherwise) so byte/str semantics match the RESP2 legacy
parser.
r   r   r   r   r   Tr   r   r   r   r   r   )r}   r   r   r   rj   ru   rY   r~   r   r   r   )r_   rl   rm   r   r   r   r   s          r`   rI   )SearchCommands._parse_hybrid_search_resp3  s    /2iik:kda|A!k:v%!$S]!3"3v;/ 
 )+	2.H(D))x~~?OP?OtqQ 2?OPQ}X4HI	 / cggoq9:WWZ, )91!=>	
 	
 ;  Qs   D.!D4c                 B   UR                  5        VVs0 s H  u  p4[        U5      U_M     nnnSU;   a"  [        [        US   5      [        US   5      S9$ U R                  " S0 UD6n/ nUR                  S/ 5       H  n[        U[        5      (       aZ  UR                  UR                  5        VV	s0 s H+  u  p[        U5      U R                  U	[        U5      U5      _M-     sn	n5        Mr  [        USS9n
UR                  U
R                  5        VV	s0 s H  u  pXR                  XU5      _M     sn	n5        M     [        [        UR                  SS	5      5      UUR                  S
/ 5      [        UR                  SS	5      5      S9$ s  snnf s  sn	nf s  sn	nf )z=Parse RESP3 FT.HYBRID into the approved unified HybridResult.r   r   r   r   r   Tr   r   r   r   r   r   r   )r}   r   r   r   r   rj   ru   rY   r~   r   r   r   r   )r_   rl   rm   r   r   r   r   r   rx   r   r   s              r`   r^   1SearchCommands._parse_hybrid_search_resp3_unified0  s   .1iik:kda|A!k:v%!$S]!3"3v;/ 
 66@@(*	2.H(D))
 +3..*:	 +;JC %S)4+J+J!<#4o,  +;	 *(E	
 +4//*;	 +<JC <<!  +<	 /* cggoq9:WWZ, )91!=>	
 	
? ;s   F32FFc                      0 nS H;  nU R                  U5      n[        USS 5      nU(       d  M*  UR                  U5        M=     U=(       d    S $ )N)re   post_processingr   )rj   r   update)rm   	encodingssource_namesourcesource_encodingss        r`   r   &SearchCommands._hybrid_field_encodingsX  sQ    	7KZZ,F&v/I4P  !12	 8
  D rc   c                 6    U(       a  X;  a  U $ [        XU5      $ rt   )r   )r   rx   r   s      r`   r   )SearchCommands._decode_hybrid_field_valueb  s    #"<L!%o>>rc   c                    UR                  5        VVs0 s H  u  p4[        U5      U_M     nnnSU;   a  U$ SU;   ai  US    VVVs/ s HQ  n[        U[        5      (       a/  UR                  5        VVs0 s H  u  p4[        U5      U_M     snnO	[	        USS9PMS     snnnUS'   SU;   a"  US    Vs/ s H  n[        U5      PM     snUS'   U$ s  snnf s  snnf s  snnnf s  snf )a3  Normalise RESP3 FT.HYBRID map keys while preserving native shape.

``protocol=3`` + ``legacy_responses=True`` keeps the RESP3 dict
surface, but HYBRID uses ``NEVER_DECODE`` so result values mirror
legacy RESP2 bytes. Decode only structural keys so callers can use
the same native RESP3 key names as before.
r   r   Tr   r   )r}   r   ru   rY   r   )r_   rl   rm   r   r   r   r   s          r`   rE   0SearchCommands._parse_hybrid_search_resp3_nativeh  s     /2iik:kda|A!k:vJ
  	N	 +D dD)) 15

=a!#="4T:; +	C	N 8;JH1|AHC
O
 ; > Is#   C.C4CC3C#Cc                    [        U[        5      (       d  U R                  " U40 UD6$ UR                  5        VVs0 s H  u  p4[	        U5      U_M     nnn0 nUR                  S0 5      nUR                  5        Hx  u  pxU(       d  M  / n	U HU  n
U
R                  5        H>  u  p[        U5      nUR                  S5      (       a  USS nU	R                  XS.5        M@     MW     U	(       d  Mt  XU'   Mz     U$ s  snnf )zParse RESP3 FT.SPELLCHECK response into unified format.

RESP3 format:
    {"results": {"term": [{"suggestion": score}, ...], ...}}
Unified format (matches RESP2 parsed output):
    {"term": [{"score": score_str, "suggestion": suggestion}, ...], ...}
r   z.0Nr   )	ru   rY   r?   r}   r   rj   r   endswithr~   )r_   rl   rm   r   r   r   r   termsuggestionsterm_correctionssuggestion_dictr   r   	score_strs                 r`   rL   &SearchCommands._parse_spellcheck_resp3  s     #t$$))#888 /2iik:kda|A!k:'')R(!(D!#.)8)>)>)@%J !$E
I ))$//$-crN	 %++"+F *A $/  $4D!' "1( / ;s   C9c           	         US   nUR                  S5      nUc  UR                  S5      nUc  UR                  S5      nUc  UR                  S5      nUc  UR                  S5      nUR                  S5      nUc  UR                  S5      nUc  UR                  S	5      nUc  UR                  S
5      nUc  UR                  S5      n[        U[        5      (       a  [        U5      US.n[        U[        5      (       a$  U R                  XC[        UR                  5      S9nO1[        R                  " UUR                  SS5      [        USS5      S9nU R                  U5      nXe4$ )zExtract ``(result, profile_data_dict)`` from a RESP3 FT.PROFILE
response.  ``profile_data_dict`` has its keys/values normalised
to strings but is otherwise left as the native RESP3 dict.
re   Resultss   Resultsr   s   resultsr   Profiles   Profileprofiles   profiler   )r   r   re   r   r   r   F)r   r   )rj   ru   r   r   r   rJ   boolr   r"   r   r   _to_string_recursive)r_   rl   rm   re   results_datar   r   s          r`   _extract_resp3_profile_parts+SearchCommands._extract_resp3_profile_parts  sg   
 w wwy)77:.L779-L77:.L771:Lwwy)77:.L779-L77:.L771:L
 lD))!$\!2'L e-..00d5==6I 1 F &&J2#E>5AF
 00>##rc   c                     [        U[        5      (       a  U R                  " U40 UD6$ U R                  " U40 UD6u  p4[        U[        5      (       a   SU;   =(       d    SU;   nU R                  XES9nU[        U5      4$ )ax  Parse RESP3 FT.PROFILE response into ``(result, ProfileInformation)``.

RESP3 format (aligned, RediSearch >= MOD-6816):
    {"Results": {search/aggregate result dict},
     "Profile": {profile information dict}}

Older RediSearch versions may return a list (same as RESP2) even
when the connection uses RESP3.  In that case we delegate to the
RESP2 ``_parse_profile`` parser.
ShardsCoordinator)flat_top)ru   r   r=   r   rY   _resp3_profile_dict_to_listr    )r_   rl   rm   r   r   r%  s         r`   rK   #SearchCommands._parse_profile_resp3  s     c4  &&s5f55#@@OO lD))</P=L3PH;; < L ),777rc   c                     [        U[        5      (       a  U R                  " U40 UD6$ U R                  " U40 UD6u  p4[        U[        5      (       a  SU;   d  SU;   d  U R                  U5      nU[        U5      4$ )a  Parse RESP3 FT.PROFILE for the unified shape.

Redis < 7.9.0 returns RESP2 profile data as nested list-of-pairs,
while RESP3 returns the same data as a dict.  Convert that pre-7.9
RESP3 dict back to the RESP2 list shape so the unified surface is
protocol-independent.  Redis >= 7.9.0 coordinator profiles contain
``Shards``/``Coordinator`` keys and stay as dicts, matching the
RESP2 unified parser.
r#  r$  )ru   r   rU   r   rY   r&  r    )r_   rl   rm   r   r   s        r`   r]   +SearchCommands._parse_profile_resp3_unified  s|     c4  ..s=f==#@@OOlD))$(E;;LIL),777rc   c                 0   ^^^ S mSUUU4S jjmT" U SS9$ )a  Convert a RESP3 profile dict into the RESP2 wire list shape.

Pre-7.9.0 servers serialise the RESP2 profile as a list of
``[key, value]`` pairs at the top level, with nested structures
as flat alternating key-value lists.  Post-7.9.0 servers serialise
the top level itself as a flat ``[key, value, key, value]`` list
(with ``"Shards"``/``"Coordinator"`` keys).  ``flat_top`` selects
between these two top-level shapes; nested dicts always use the
flat alternating form.

Key structural difference: when a dict value is a list of dicts
(e.g. ``"Child iterators": [{...}, {...}]``), RESP2 expands each
dict as a separate sibling element in the parent flat list rather
than keeping them nested inside a single value.
c                 h    [        U [        5      =(       a    U =(       a    [        U S   [        5      $ )Nr   )ru   r   rY   )objs    r`   _is_list_of_dictsESearchCommands._resp3_profile_dict_to_list.<locals>._is_list_of_dicts  s$    c4(MSMZA5MMrc   c                   > [        U [        5      (       a  U(       a}  T	(       dv  / nU R                  5        H^  u  p4U/nT" U5      (       a!  U H  nUR                  T" U5      5        M     OUR                  T" U5      5        UR                  U5        M`     U$ / nU R                  5        H\  u  p4UR                  U5        T" U5      (       a"  U H  nUR                  T" U5      5        M     ME  UR                  T" U5      5        M^     U$ [        U [        5      (       a  U  Vs/ s H  nT" U5      PM     sn$ U $ s  snf rt   )ru   rY   r}   r~   r   )
r,  	top_levelr   r   r   entryr   _convertr-  r%  s
          r`   r2  <SearchCommands._resp3_profile_dict_to_list.<locals>._convert  s   #t$$XF #		!",Q//() %Xd^ < )* "LL!5e, !, "MF #		a(,Q//() &htn = )* #MM(1+6 !, "MC&&36734377J 8s   (D?T)r0  Fr   )r   r%  r2  r-  s    `@@r`   r&  *SearchCommands._resp3_profile_dict_to_list
  s"    $	N	 	6 --rc   c                    [        U [        5      (       a  [        U 5      $ [        U [        5      (       aY  U R	                  5        VVs0 s H;  u  p[        U[        5      (       a  [        U5      OU[
        R                  U5      _M=     snn$ [        U [        5      (       a&  U  Vs/ s H  n[
        R                  U5      PM     sn$ U $ s  snnf s  snf )zRecursively convert bytes keys/values to strings in nested
structures.  Non-bytes scalars (int, float, None, bool) pass
through unchanged.
)ru   r   r   rY   r}   r1   r  r   )r,  r   r   r   s       r`   r  #SearchCommands._to_string_recursive>  s     c5!!$$c4  
  IIK	 (DA $.a#7#7QQ"77:; (	  c4  JMN#$N77=#NN
 Os   	AC(Cc                 $    U R                  U5      $ )z;Parse RESP3 FT.INFO response, normalising bytes to strings.r  r   s      r`   r[    SearchCommands._parse_info_resp3Q  s    ((--rc   c                     / nU R                  S5      =(       d    / nU R                  5        H/  u  p4US:X  a  M  UR                  U5        UR                  U5        M1     UR                  U5        U$ )zsConvert a RESP3-style attribute dict back into the RESP2 flat
list (key-value pairs followed by bare flag tokens).
r   )rj   r}   r~   extend)	attr_dictr   r   r   r   s        r`   _flatten_info_attribute&SearchCommands._flatten_info_attributeU  sb    
 g&,"OO%DAG|KKNKKN	 &
 	Erc   c                     U R                  U5      nUR                  S5      n[        U[        5      (       a<  U Vs/ s H+  n[        U[        5      (       a  U R                  U5      OUPM-     snUS'   U$ s  snf )zxParse RESP3 FT.INFO into the legacy RESP2 flat shape so
``legacy_responses=True`` on a RESP3 wire matches RESP2 output.
r   )r  rj   ru   r   rY   r>  )r_   rl   rm   r   attrsr   s         r`   rG   *SearchCommands._parse_info_resp3_to_legacyd  s}     ((-&eT"" ""!D 7At6L6L,,T2RVV!"D 	"s   2A6c                     U(       d  0 $ UR                  5        VVs0 s H  u  p4[        U5      [        U5      _M     snn$ s  snnf )zAParse RESP3 FT.CONFIG GET response, normalising bytes to strings.)r}   r   )r_   rl   rm   r   r   s        r`   r\   &SearchCommands._parse_config_get_resp3q  s7    I=@YY[I[TQQa0[IIIs   !Ac                 *    U(       a  [        U5      $ 0 $ )z>Parse RESP3 FT.CONFIG GET back to the RESP2 legacy dict shape.)rY   r   s      r`   rM   0SearchCommands._parse_config_get_resp3_to_legacyw  s    tCy'R'rc   c                 6    U(       d  0 $ U R                  U5      $ )z>Parse RESP3 FT.SYNDUMP response, normalising bytes to strings.r9  r   s      r`   rN   #SearchCommands._parse_syndump_resp3{  s    I((--rc   c                      U R                  XS9$ )zD
Create a new batch indexer from the client with a given chunk size
)
chunk_size)BatchIndexer)r_   rJ  s     r`   batch_indexerSearchCommands.batch_indexer  s        ==rc   fieldsno_term_offsetsno_field_flags	stopwords
definitionno_highlightno_term_frequenciesskip_initial_scanc                    [         U R                  /nUb  XR                  -  nU(       a  UR                  [        5        Ub;  [        U[        5      (       a&  UR                  [        5        UR                  U5        U(       a  UR                  [        5        U(       a  UR                  [        5        U(       a  UR                  [        5        U	(       a  UR                  [        5        U
(       a  UR                  [        5        UbQ  [        U[        [        [        45      (       a1  U[         [#        U5      /-  n[#        U5      S:  a  U[        U5      -  nUR                  S5         U[        [$        R&                  " S U 5       6 5      -  nU R,                  " U6 $ ! [(         a    XR+                  5       -  n N-f = f)a  
Creates the search index. The index must not already exist.

For more information, see https://redis.io/commands/ft.create/

Args:
    fields: A list of Field objects.
    no_term_offsets: If `true`, term offsets will not be saved in the index.
    no_field_flags: If true, field flags that allow searching in specific fields
                    will not be saved.
    stopwords: If provided, the index will be created with this custom stopword
               list. The list can be empty.
    definition: If provided, the index will be created with this custom index
                definition.
    max_text_fields: If true, indexes will be encoded as if there were more than
                     32 text fields, allowing for additional fields beyond 32.
    temporary: Creates a lightweight temporary index which will expire after the
               specified period of inactivity. The internal idle timer is reset
               whenever the index is searched or added to.
    no_highlight: If true, disables highlighting support. Also implied by
                  `no_term_offsets`.
    no_term_frequencies: If true, term frequencies will not be saved in the
                         index.
    skip_initial_scan: If true, the initial scan and indexing will be skipped.

r   SCHEMAc              3   @   #    U  H  oR                  5       v   M     g 7frt   
redis_args.0fs     r`   	<genexpr>.SearchCommands.create_index.<locals>.<genexpr>       *J6a<<>>6   )
CREATE_CMD
index_nameargsr~   r)   ru   r   r*   r%   r'   r&   r(   r,   r   tuplesetr+   r   	itertoolschain	TypeErrorrZ  execute_command)r_   rN  rO  rP  rQ  rR  max_text_fields	temporaryrS  rT  rU  rd  s               r`   create_indexSearchCommands.create_index  sS   N DOO,!OO#DKK& Z	3%?%?KK	"KK	"KK	"KKKK!KK KK( Z	D%;M%N%NYI//D9~!Y'H	(D*J6*JKLLD ##T**  	(%%''D	(s   0&F% %GGc                     [         U R                  SS/n U[        [        R                  " S U 5       6 5      -  nU R                  " U6 $ ! [
         a    X!R                  5       -  n N-f = f)z
Alter the existing search index by adding new fields. The index
must already exist.

### Parameters:

- **fields**: a list of Field objects to add for the index

For more information see `FT.ALTER <https://redis.io/commands/ft.alter>`_.
rW  ADDc              3   @   #    U  H  oR                  5       v   M     g 7frt   rY  r[  s     r`   r^  2SearchCommands.alter_schema_add.<locals>.<genexpr>  r`  ra  )	ALTER_CMDrc  r   rg  rh  ri  rZ  rj  )r_   rN  rd  s      r`   alter_schema_addSearchCommands.alter_schema_add  sn     4??He<	(D*J6*JKLLD ##T**  	(%%''D	(s   &A A*)A*delete_documentsc                     [         U R                  /n[        U[        5      (       a  USL a  SOSnU(       a  UR	                  U5        U R
                  " U6 $ )a1  
Drop the index if it exists.
Replaced `drop_index` in RediSearch 2.0.
Default behavior was changed to not delete the indexed documents.

### Parameters:

- **delete_documents**: If `True`, all documents will be deleted.

For more information see `FT.DROPINDEX <https://redis.io/commands/ft.dropindex>`_.
TDD )DROPINDEX_CMDrc  ru   r  r~   rj  )r_   rv  rd  
delete_strs       r`   	dropindexSearchCommands.dropindex  sY     t/ *D116F$6N  	 KK
###T**rc   c
                 ,   U(       d  U	(       a  Sn[         U R                  X/nU(       a  UR                  S5        Ub"  UR                  S5        UR                  U5        U(       aA  UR                  S5        U(       a  UR                  S5        U	(       a  UR                  S5        U(       a  USU/-  nUR                  S5        U[        [        R
                  " U
R                  5       6 5      -  nUb  UR                  " U6 $ U R                  " U6 $ )	zC
Internal add_document used for both batch and single doc indexing
TNOSAVEPAYLOADREPLACEPARTIALNOCREATELANGUAGEFIELDS)ADD_CMDrc  r~   r   rg  rh  r}   rj  )r_   doc_idconnnosaver   r   replacepartiallanguage	no_createrN  rd  s               r`   _add_documentSearchCommands._add_document  s    " iG&8KK!KK	"KK KK	"I&J'Z**DHY__flln566''..##T**rc   c                     [         U R                  X/nU(       a  UR                  S5        U(       a  USU/-  nUb  UR                  " U6 $ U R                  " U6 $ )zH
Internal add_document_hash used for both batch and single doc indexing
r  r  )ADDHASH_CMDrc  r~   rj  )r_   r  r  r   r  r  rd  s          r`   _add_document_hash!SearchCommands._add_document_hash$  s]     T__f<KK	"Z**D''..##T**rc   z2.0.0z2deprecated since redisearch 2.0, call hset insteadversionreasonr  r  r   r   r  r  r  r  c	                 :    U R                   " U4SUUUUUUUS.U	D6$ )a  
Add a single document to the index.

Args:

    doc_id: the id of the saved document.
    nosave: if set to true, we just index the document, and don't
              save a copy of it. This means that searches will just
              return ids.
    score: the document ranking, between 0.0 and 1.0
    payload: optional inner-index payload we can save for fast
             access in scoring functions
    replace: if True, and the document already is in the index,
             we perform an update and reindex the document
    partial: if True, the fields specified will be added to the
               existing document.
               This has the added benefit that any fields specified
               with `no_index`
               will not be reindexed again. Implies `replace`
    language: Specify the language used for document tokenization.
    no_create: if True, the document is only updated and reindexed
                 if it already exists.
                 If the document does not exist, an error will be
                 returned. Implies `replace`
    fields: kwargs dictionary of the document fields to be saved
            and/or indexed.
            NOTE: Geo points should be encoded as strings of "lon,lat"
N)r  r  r   r   r  r  r  r  )r  )
r_   r  r  r   r   r  r  r  r  rN  s
             r`   add_documentSearchCommands.add_document8  sB    V !!

 
 	
rc   c                 &    U R                  USX#US9$ )a  
Add a hash document to the index.

### Parameters

- **doc_id**: the document's id. This has to be an existing HASH key
              in Redis that will hold the fields the index needs.
- **score**:  the document ranking, between 0.0 and 1.0
- **replace**: if True, and the document already is in the index, we
              perform an update and reindex the document
- **language**: Specify the language used for document tokenization.
N)r  r   r  r  )r  )r_   r  r   r  r  s        r`   add_document_hash SearchCommands.add_document_hashp  s%      &&Uw ' 
 	
rc   zdeprecated since redisearch 2.0c                     [         U R                  U/nU(       a  UR                  S5        Ub  UR                  " U6 $ U R                  " U6 $ )z
Delete a document from index
Returns 1 if the document was deleted, 0 if not

### Parameters

- **delete_actual_document**: if set to True, RediSearch also delete
                              the actual document if it is in the index
rx  )DEL_CMDrc  r~   rj  )r_   r  r  delete_actual_documentrd  s        r`   delete_documentSearchCommands.delete_document  sK     &1!KK''..##T**rc   r   c                 
   U R                   R                  U5      nUR                  5        VVs0 s H%  u  pE[        U5      [	        U[        U5      U5      _M'     nnn US	 [        SSU0UD6$ s  snnf ! [
         a     Nf = f)
Load a single document by id

- **field_encodings**: optional dict mapping field names to encodings.
  If a field's encoding is ``None`` the raw bytes value is preserved
  (useful for binary data such as vectors).
r   r   ri   hgetallr}   r   r   KeyErrorr   r_   r   r   rN  r   r   s         r`   load_documentSearchCommands.load_document  s     $$R( 
& O/<?OTT& 	 

	t (2(((
  		s   ,A/A5 5
BBc                 F    U R                   " [        U R                  /UQ76 $ )zo
Returns the full contents of multiple documents.

### Parameters

- **ids**: the ids of the saved documents.

)rj  MGET_CMDrc  )r_   idss     r`   rj   SearchCommands.get  s      ##HdooDDDrc   c                 n    U R                  [        U R                  5      nU R                  [        U5      $ )
Get info an stats about the the current index, including the number of
documents, memory consumption, etc

For more information see `FT.INFO <https://redis.io/commands/ft.info>`_.
rj  r4   rc  rq   r_   rl   s     r`   r   SearchCommands.info  s-     ""8T__=""8S11rc   query_paramsc                    Uc  / $ / n[        U5      S:  ai  UR                  S5        UR                  [        U5      S-  5        UR                  5        H'  u  p4UR                  U5        UR                  U5        M)     U$ )Nr   PARAMSr   )r   r~   r}   )r_   r  rd  rx   r   s        r`   get_params_argsSearchCommands.get_params_args  sw     I|q KK!KKL)A-.*002
C E" 3 rc   c                    U R                   /n[        U[        5      (       a  [        U5      n[        U[        5      (       d  [	        S[        U5       35      eX1R                  5       -  nX0R                  U5      -  nX14$ )NzBad query type )rc  ru   r   r!   
ValueErrorr   get_argsr  )r_   re   r  rd  s       r`   _mk_query_argsSearchCommands._mk_query_args  ss      eS!!%LE%''tE{m<==  $$\22{rc   re   c                    U R                  XS9u  p1[        R                  " 5       n0 n[        [	        U R
                  5      S5      (       d	  SU[        '   [        U [        5      (       a	  XS'   SUS'   U R                  " [        /UQ70 UD6n[        U[        5      (       a  U$ U R                  [        Xa[        R                  " 5       U-
  S-  S9$ )	n  
Search the index for a given query, and return a result of documents

### Parameters

- **query**: the search query. Either a text for simple queries with
             default parameters, or a Query object for complex queries.
             See RediSearch's documentation on query format

For more information see `FT.SEARCH <https://redis.io/commands/ft.search>`_.
r  rf   Tre   r   r        @@re   r   r  time	monotonicr   r   ri   r	   ru   r
   rj  r6   rq   r_   re   r  rd  stoptionsrl   s          r`   searchSearchCommands.search  s      ))%)K^^%&:4;;&GKK$(GL!dH%%$G"#GJ"":@@@c8$$J""DNN4Dr4IV3S # 
 	
rc   combine_methodr  params_substitutiontimeoutr   returnc                    U R                   n0 n[        U/n	U	R                  UR                  5       5        U(       a  U	R                  UR                  5       5        U(       a#  U	R                  UR	                  5       5        X8S'   U(       a   U	R                  U R                  U5      5        U(       a  U	R                  SU45        U(       a$  SUS'   U	R                  UR	                  5       5        SU[        '   XS'   U R                  " U	0 UD6n
[        U
[        5      (       a  U
$ U R                  " [        U
40 UD6$ )  
Execute a hybrid search using both text and vector queries

Args:
    - **query**: HybridQuery object
                Contains the text and vector queries
    - **combine_method**: CombineResultsMethod object
                Contains the combine method and parameters
    - **post_processing**: HybridPostProcessingConfig object
                Contains the post processing configuration
    - **params_substitution**: Dict[str, Union[str, int, float, bytes]]
                Contains the parameters substitution
    - **timeout**: int - contains the timeout in milliseconds
    - **cursor**: HybridCursorQuery object - contains the cursor configuration


For more information see `FT.SEARCH <https://redis.io/commands/ft.hybrid>`.
r  TIMEOUTTr   re   rc  r8   r<  r  
build_argsr  r	   rj  ru   r
   rq   r_   re   r  r  r  r  r   indexr  piecesrl   s              r`   hybrid_searchSearchCommands.hybrid_search  s   8 e$enn&'MM.1134MM/4467)8%&MM$../BCDMM9g./ $GHMM&++-.
 !% ""F6g6c8$$J"":s>g>>rc   c                 R    U R                  XS9u  p4U R                  " [        /UQ76 $ )zReturns the execution plan for a complex query.

For more information see `FT.EXPLAIN <https://redis.io/commands/ft.explain>`_.
r  )r  rj  EXPLAIN_CMD)r_   re   r  rd  
query_texts        r`   explainSearchCommands.explain@  s0      ..u.P##K7$77rc   c                     [        S5      e)Nz#EXPLAINCLI will not be implemented.)NotImplementedError)r_   re   s     r`   explain_cliSearchCommands.explain_cliL  s    !"GHHrc   c                    [        U[        5      (       a9  [        UR                  5      n[        U R
                  /UR                  5       -   nOH[        U[        5      (       a'  Sn[        SU R
                  /UR                  5       -   nO[        SU5      eX@R                  U5      -  nU R                  " U6 nU R                  [        XQUS9$ )Q  
Issue an aggregation query.

### Parameters

**query**: This can be either an `AggregateRequest`, or a `Cursor`

An `AggregateResult` object is returned. You can access the rows from
its `rows` property, which will always yield the rows of the result.

For more information see `FT.AGGREGATE <https://redis.io/commands/ft.aggregate>`_.
TREAD	Bad queryr  ru   r   r  r   r:   rc  r  r   
CURSOR_CMDr  r  rj  rq   r_   re   r  r   rk   raws         r`   	aggregateSearchCommands.aggregateO  s    " e-..emm,J $//2U5E5E5GGCv&&Jvt7%:J:J:LLC[%00##L11""C(""3
 # 
 	
rc   r  r   c                    U(       a6  [        U[        5      (       a  US   Ul        UnO[        US   5      nUS   nOS n[        U[        5      (       a  UR                  (       a  US   nUSS  nOS nUSS  n[        XdU5      $ )Nr   r   r   )ru   r   r   r   _with_schemar   )r_   r  re   r   r   schemar   s          r`   r   $SearchCommands._get_aggregate_resulto  s     %((F	Aa&CFe-..53E3EVFqr7DFqr7DtV44rc   limitedc                    [         R                  " 5       n[        U R                  S/nU(       a  UR	                  S5        UR	                  S5        [        U[        5      (       a  SUS'   XQR                  5       -  nOK[        U[        5      (       a+  SUS'   XQR                  5       -  nXPR                  U5      -  nO[        S5      eU R                  " U6 nU R                  [        Xa[         R                  " 5       U-
  S-  S	9$ )
a?  
Performs a search or aggregate command and collects performance
information.

### Parameters

**query**: This can be either an `AggregateRequest` or `Query`.
**limited**: If set to True, removes details of reader iterator.
**query_params**: Define one or more value parameters.
Each parameter has a name and a value.

ry  LIMITEDQUERY	AGGREGATEr   r   z5Must provide AggregateRequest object or Query object.r  r  )r  r  r<   rc  r~   ru   r   r  r!   r  r  r  rj  rq   )r_   re   r  r  r  rk   rl   s          r`   r  SearchCommands.profile  s    * ^^DOOR0JJy!

7e-.. CF##%%Cu%%CF>>##C''55CTUU""C(""T^^5E5Jf4T # 
 	
rc   c                    [         U R                  U/nU(       a  UR                  SU/5        U(       a  UR                  SSU/5        U(       a  UR                  SSU/5        U R                  " U6 nU R	                  [         U5      $ )al  
Issue a spellcheck query

Args:

    query: search query.
    distance: the maximal Levenshtein distance for spelling
               suggestions (default: 1, max: 4).
    include: specifies an inclusion custom dictionary.
    exclude: specifies an exclusion custom dictionary.

For more information see `FT.SPELLCHECK <https://redis.io/commands/ft.spellcheck>`_.
DISTANCETERMSINCLUDEEXCLUDEr>   rc  r<  rj  rq   r_   re   distanceincludeexcluderk   rl   s          r`   
spellcheckSearchCommands.spellcheck  sw     t6JJ
H-.JJG45JJG45""C("">377rc   nametermsc                 R    [         U/nUR                  U5        U R                  " U6 $ )zAdds terms to a dictionary.

### Parameters

- **name**: Dictionary name.
- **terms**: List of items for adding to the dictionary.

For more information see `FT.DICTADD <https://redis.io/commands/ft.dictadd>`_.
)DICT_ADD_CMDr<  rj  r_   r  r  rk   s       r`   dict_addSearchCommands.dict_add  +     T"

5##S))rc   c                 R    [         U/nUR                  U5        U R                  " U6 $ )zDeletes terms from a dictionary.

### Parameters

- **name**: Dictionary name.
- **terms**: List of items for removing from the dictionary.

For more information see `FT.DICTDEL <https://redis.io/commands/ft.dictdel>`_.
)DICT_DEL_CMDr<  rj  r  s       r`   dict_delSearchCommands.dict_del  r  rc   c                 0    [         U/nU R                  " U6 $ )zDumps all terms in the given dictionary.

### Parameters

- **name**: Dictionary name.

For more information see `FT.DICTDUMP <https://redis.io/commands/ft.dictdump>`_.
)DICT_DUMP_CMDrj  )r_   r  rk   s      r`   	dict_dumpSearchCommands.dict_dump  s     d###S))rc   8.0.0Ddeprecated since Redis 8.0, call config_set from core module insteadoptionr   c                 <    [         SX/nU R                  " U6 nUS:H  $ )Set runtime configuration option.

### Parameters

- **option**: the name of the configuration option.
- **value**: a value for the configuration option.

For more information see `FT.CONFIG SET <https://redis.io/commands/ft.config-set>`_.
SETOKr@   rj  r_   r  r   rk   r  s        r`   
config_setSearchCommands.config_set  s*     5&0""C(d{rc   Ddeprecated since Redis 8.0, call config_get from core module insteadc                 ^    [         SU/nU R                  " U6 nU R                  [         U5      $ )Get runtime configuration option value.

### Parameters

- **option**: the name of the configuration option.

For more information see `FT.CONFIG GET <https://redis.io/commands/ft.config-get>`_.
GETr@   rj  rq   r_   r  rk   rl   s       r`   
config_getSearchCommands.config_get  s3     5&)""C("":s33rc   tagfieldc                 D    U R                  [        U R                  U5      $ )z
Return a list of all possible tag values

### Parameters

- **tagfield**: Tag field name

For more information see `FT.TAGVALS <https://redis.io/commands/ft.tagvals>`_.
)rj  TAGVALS_CMDrc  )r_   r$  s     r`   tagvalsSearchCommands.tagvals  s     ##K(KKrc   aliasc                 B    U R                  [        XR                  5      $ )z
Alias a search index - will fail if alias already exists

### Parameters

- **alias**: Name of the alias to create

For more information see `FT.ALIASADD <https://redis.io/commands/ft.aliasadd>`_.
)rj  ALIAS_ADD_CMDrc  r_   r)  s     r`   aliasaddSearchCommands.aliasadd$  s     ##M5//JJrc   c                 B    U R                  [        XR                  5      $ )z
Updates an alias - will fail if alias does not already exist

### Parameters

- **alias**: Name of the alias to create

For more information see `FT.ALIASUPDATE <https://redis.io/commands/ft.aliasupdate>`_.
)rj  ALIAS_UPDATE_CMDrc  r,  s     r`   aliasupdateSearchCommands.aliasupdate1  s     ##$4e__MMrc   c                 .    U R                  [        U5      $ )z
Removes an alias to a search index

### Parameters

- **alias**: Name of the alias to delete

For more information see `FT.ALIASDEL <https://redis.io/commands/ft.aliasdel>`_.
)rj  ALIAS_DEL_CMDr,  s     r`   aliasdelSearchCommands.aliasdel>  s     ##M599rc   c                 x   U R                  SS9nU H  n[        XR                  UR                  /nUR	                  S5      (       a  UR                  S5        UR                  (       a,  UR                  S5        UR                  UR                  5        UR                  " U6   M     UR                  5       S   $ )a  
Add suggestion terms to the AutoCompleter engine. Each suggestion has
a score and string.
If kwargs["increment"] is true and the terms are already in the
server's dictionary, we increment their scores.

For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd/>`_.
Ftransaction	incrementINCRr  	pipelineSUGADD_COMMANDstringr   rj   r~   r   rj  executer_   rx   r  rm   pipesugrd  s          r`   sugaddSearchCommands.sugaddJ  s     }}}/C"CSYY?Dzz+&&F#{{I&CKK(  $'  ||~b!!rc   rx   c                 .    U R                  [        U5      $ )z
Return the number of entries in the AutoCompleter index.

For more information see `FT.SUGLEN <https://redis.io/commands/ft.suglen>`_.
)rj  SUGLEN_COMMAND)r_   rx   s     r`   suglenSearchCommands.suglena  s     ##NC88rc   r@  c                 .    U R                  [        X5      $ )z
Delete a string from the AutoCompleter index.
Returns 1 if the string was found and deleted, 0 otherwise.

For more information see `FT.SUGDEL <https://redis.io/commands/ft.sugdel>`_.
)rj  SUGDEL_COMMAND)r_   rx   r@  s      r`   sugdelSearchCommands.sugdeli  s     ##NC@@rc   prefixfuzzynumr   with_payloadsc                 8   [         XSU/nU(       a  UR                  [        5        U(       a  UR                  [        5        U(       a  UR                  [        5        U R
                  " U6 n/ n	U(       d  U	$ [        XVU5      n
U
 Vs/ s H  oPM     sn$ s  snf )  
Get a list of suggestions from the AutoCompleter, for a given prefix.

Parameters:

prefix : str
    The prefix we are searching. **Must be valid ascii or utf-8**
fuzzy : bool
    If set to true, the prefix search is done in fuzzy mode.
    **NOTE**: Running fuzzy searches on short (<3 letters) prefixes
    can be very
    slow, and even scan the entire index.
with_scores : bool
    If set to true, we also return the (refactored) score of
    each suggestion.
    This is normally not needed, and is NOT the original score
    inserted into the index.
with_payloads : bool
    Return suggestion payloads
num : int
    The maximum number of results we return. Note that we might
    return less. The algorithm trims irrelevant suggestions.

Returns:

list:
     A list of Suggestion objects. If with_scores was False, the
     score of all suggestions is 1.

For more information see `FT.SUGGET <https://redis.io/commands/ft.sugget>`_.
MAXSUGGET_COMMANDr~   r.   r-   r/   rj  r#   )r_   rx   rO  rP  rQ  r   rR  rd  rl   r   parserr   s               r`   suggetSearchCommands.suggetr  s    P UC8KKKK
#KK%""D)N!+cB!"6a6"""s   	Bgroupidskipinitialc                     [         U R                  U/nU(       a  UR                  S/5        UR                  U5        U R                  " U6 $ )a  
Updates a synonym group.
The command is used to create or update a synonym group with
additional terms.
Only documents which were indexed after the update will be affected.

Parameters:

groupid :
    Synonym group id.
skipinitial : bool
    If set to true, we do not scan and index.
terms :
    The terms.

For more information see `FT.SYNUPDATE <https://redis.io/commands/ft.synupdate>`_.
r,   )SYNUPDATE_CMDrc  r<  rj  )r_   r[  r\  r  rk   s        r`   	synupdateSearchCommands.synupdate  sD    $ doow7JJ)*+

5##S))rc   c                 n    U R                  [        U R                  5      nU R                  [        U5      $ )z
Dumps the contents of a synonym group.

The command is used to dump the synonyms data structure.
Returns a list of synonym terms and their synonym group ids.

For more information see `FT.SYNDUMP <https://redis.io/commands/ft.syndump>`_.
)rj  rB   rc  rq   r  s     r`   syndumpSearchCommands.syndump  s-     "";@"";44rc   )rD   rX   rF   rO   rR   rZ   rt   r4  )d   )	FFNNFNFFF)NF      ?NFFNF)Nre  NF)Fre  NFFNF)re  NF)NFNNNNN)FNNNNF
   FF)x__name__
__module____qualname____firstlineno____doc__	frozensetr6   r:   r  r8   r<   rh   ra   rq   staticmethodrz   r   rP   rQ   r5   r7   r9   r;   r=   r?   rA   rC   r   r   rS   rT   rU   rV   rW   rH   rJ   rI   r^   r   r   rE   rL   r   rK   r]   r&  r  r[   r>  rG   r\   rM   rN   rL  r   r   r  r   r   r   rm  r   rt  r|  r  r  r   r   r  r  r  r   r   r  rj   r   r   r   r  r  r!   r  r   r   r   r   r   r   r   r
   r  r  r  r   r   r  r   re  r"   r   r    r  r  r  r  r  r  r"  r'  r-  r1  r5  rE  rI  rM  r#   rY  r_  rb  __static_attributes__r   rc   r`   r1   r1   R   s    %	]J
KHM
^!. D D
  *
2!

,V2#J>C %N  .
68<K


+S^
:&
P ! ! ? ?
2$P/$b888( /. /.f  $.  J(.> !&$)-04"$)"'D+UD+ D+ 	D+
 DI&D+ _-D+ D+ "D+  D+L+uUDK-?'@ +(+$ +8 (+V DI+(  T "&"&3
3
 3
 	3

 $3
 3
 3
 3-3
 3
 s)3
3
j  T

" 1RS+ T+&)$sCx.1I )* 1RS
E T
E	2$T#uS#ue5K/L*L%MN#+DeCeU<R6S1S,T#U& OS!
S%Z !
 DeCeU,B&C!CDdJK!
F  :>@DRV!%.27?7? !!567? ""<=	7?
 &d3c3u6L0M+M&NO7? #7? *+7? 
|/9	:7? 7?x LP
8S%Z 
8 tCsC/E)F$FGH
8IsEz!2 I LP
%v-.
 tCsC/E)F$FGH
@55 %&6&> ?5MQ52 KO	)
U,,-)
 )
 tCsC/E)F$FGH	)

 
eFO+,.@@A	
)
V88*S *$s) **S *$s) *
*c 
* U S T 	 U4 4 4	4L LKc KN N
:c 
:".9# 9# 9A# As As A !#6#6# 6# 	6#
 6# 6# 6# 
	6#p* *4 *c *0
5rc   r1   c                      \ rS rSrS r S#S\\\4   S\\	\\\\
\\4   4      4S jjr\" 5            S$S\S\\   S\\   S	\\	\\\\
\\4   4      S
\\
   S\\   S\\\\4   4S jj5       r S#S\\\4   S\\	\\\\
\\4   4      4S jjrS%S jr\" SSS9S\S\S\4S j5       r\" SSS9S\S\4S j5       rS#S\\	\\4      4S jjr S r!    S&S\S\S\S\
S\S \S\"\#   4S! jjr$S"r%g)'AsyncSearchCommandsi  c                    #    U R                  [        U R                  5      I Sh  vN nU R                  [        U5      $  N7f)r  Nr  r  s     r`   r   AsyncSearchCommands.info  s9      ((4??CC""8S11 Ds   $AAANre   r  c                   #    U R                  XS9u  p1[        R                  " 5       n0 n[        [	        U R
                  5      S5      (       d	  SU[        '   [        U [        5      (       a	  XS'   SUS'   U R                  " [        /UQ70 UD6I Sh  vN n[        U[        5      (       a  U$ U R                  [        Xa[        R                  " 5       U-
  S-  S	9$  NI7f)
r  r  rf   Tre   r   r   Nr  r  r  r  s          r`   r  AsyncSearchCommands.search  s       ))%)K^^%&:4;;&GKK$(GL!dH%%$G"#GJ((FdFgFFc8$$J""DNN4Dr4IV3S # 
 	
 Gs   BCCA
Cr  r  r  r  r   r  c                   #    U R                   n0 n[        U/n	U	R                  UR                  5       5        U(       a  U	R                  UR                  5       5        U(       a#  U	R                  UR	                  5       5        X8S'   U(       a   U	R                  U R                  U5      5        U(       a  U	R                  SU45        U(       a$  SUS'   U	R                  UR	                  5       5        SU[        '   XS'   U R                  " U	0 UD6I Sh  vN n
[        U
[        5      (       a  U
$ U R                  " [        U
40 UD6$  N37f)r  r  r  Tr   re   Nr  r  s              r`   r  !AsyncSearchCommands.hybrid_search  s    8 e$enn&'MM.1134MM/4467)8%&MM$../BCDMM9g./ $GHMM&++-.
 !% ((&<G<<c8$$J"":s>g>> =s   DEE
4Ec                   #    [        U[        5      (       a9  [        UR                  5      n[        U R
                  /UR                  5       -   nOH[        U[        5      (       a'  Sn[        SU R
                  /UR                  5       -   nO[        SU5      eX@R                  U5      -  nU R                  " U6 I Sh  vN nU R                  [        XQUS9$  N7f)r  Tr  r  Nr  r  r  s         r`   r  AsyncSearchCommands.aggregate8  s     " e-..emm,J $//2U5E5E5GGCv&&Jvt7%:J:J:LLC[%00##L11((#..""3
 # 
 	
 /s   B<C>C?Cc                 .  #    [         U R                  U/nU(       a  UR                  SU/5        U(       a  UR                  SSU/5        U(       a  UR                  SSU/5        U R                  " U6 I Sh  vN nU R	                  [         U5      $  N7f)av  
Issue a spellcheck query

### Parameters

**query**: search query.
**distance***: the maximal Levenshtein distance for spelling
               suggestions (default: 1, max: 4).
**include**: specifies an inclusion custom dictionary.
**exclude**: specifies an exclusion custom dictionary.

For more information see `FT.SPELLCHECK <https://redis.io/commands/ft.spellcheck>`_.
r  r  r  r  Nr  r  s          r`   r  AsyncSearchCommands.spellcheckX  s      t6JJ
H-.JJG45JJG45((#.."">377 /s   A6B8B9Br  r  r  r  r   c                 X   #    [         SX/nU R                  " U6 I Sh  vN nUS:H  $  N	7f)r  r  Nr  r  r  s        r`   r  AsyncSearchCommands.config_sett  s5      5&0((#..d{ /s   *(
*r  c                 ~   #    [         SU/n0 nU R                  " U6 I Sh  vN nU R                  [         U5      $  N7f)r  r  Nr   r!  s       r`   r"  AsyncSearchCommands.config_get  sC      5&)((#.."":s33 /s   =;=r   c                 &  #    U R                   R                  U5      I Sh  vN nUR                  5        VVs0 s H%  u  pE[        U5      [	        U[        U5      U5      _M'     nnn US	 [        SSU0UD6$  NWs  snnf ! [
         a     N!f = f7f)r  Nr   r   r  r  s         r`   r  !AsyncSearchCommands.load_document  s      {{**2.. 
& O/<?OTT& 	 

	t (2((( /
  		sD   BA9B,A;%B)B ,B;B
BBBBc                   #    U R                  SS9nU H  n[        XR                  UR                  /nUR	                  S5      (       a  UR                  S5        UR                  (       a,  UR                  S5        UR                  UR                  5        UR                  " U6   M     UR                  5       I Sh  vN S   $  N7f)a  
Add suggestion terms to the AutoCompleter engine. Each suggestion has
a score and string.
If kwargs["increment"] is true and the terms are already in the
server's dictionary, we increment their scores.

For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd>`_.
Fr8  r:  r;  r  Nr<  r=  rB  s          r`   rE  AsyncSearchCommands.sugadd  s      }}}/C"CSYY?Dzz+&&F#{{I&CKK(  $'  lln$b))$s   B<C>C?Crx   rO  rP  rQ  r   rR  c                 T  #    [         XSU/nU(       a  UR                  [        5        U(       a  UR                  [        5        U(       a  UR                  [        5        U R
                  " U6 I Sh  vN n/ n	U(       d  U	$ [        XVU5      n
U
 Vs/ s H  oPM     sn$  N-s  snf 7f)rT  rU  NrV  )r_   rx   rO  rP  rQ  r   rR  rd  retr   rX  r   s               r`   rY  AsyncSearchCommands.sugget  s     P UC8KKKK
#KK%(($//N!+cB!"6a6"" 0 #s$   A1B(3B!4B(B#B(#B(r   rt   rf  rg  rh  )&rj  rk  rl  rm  r   r   r   r!   r   r   r   r   r   r  r   r   r   r   r   r   r   r
   r  r   r   r  r  r   r  r  r"  r   r  rE  r   r#   rY  rq  r   rc   r`   rs  rs    s%   	2 LP!
S%Z !
 tCsC/E)F$FGH!
F  :>@DRV!%.27?7? !!567? ""<=	7?
 &d3c3u6L0M+M&NO7? #7? *+7? 
|/9	:7? 7?x LP
_f,-
 tCsC/E)F$FGH
@88 Us 3 4 	 U4s 4s 4	4)xS#X7O )**6 !#6#6# 6# 	6#
 6# 6# 6# 
	6# 6#rc   rs  )\rg  r  typingr   r   r   r   r   redis._parsers.helpersr   redis.clientr	   r
   "redis.commands.search.hybrid_queryr   r   r   r   #redis.commands.search.hybrid_resultr   r   redis.utilsr   r   r   r   r   helpersr   r   aggregationr   r   r   documentr   fieldr   index_definitionr   profile_informationr    re   r!   r   r"   r   r#   r$   rb  rs  r6   r  r  rz  r  EXPLAINCLI_CMDr  r:   r<   r  r>   r  r
  r  r  r@   r&  r+  r0  r4  r4   r?  rL  rH  rW  r^  rB   r8   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r1   rs  r   rc   r`   <module>r     sF     3 3 0 /  Q  A 
   - 3   (

	

 

 
# 
	
		#
z5 z5z3k#. k#rc   