
    ph                        S SK r S SKrS SKJrJrJrJr  S SKJrJ	r	  S SK
Jr  SSKJr  SSK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r"Sr#Sr$Sr%Sr&Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.S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@S0rAS1rBS2rCS3rDS4rES5rFS6rGS7rHS8rIS9rJ " S: S;5      rK " S< S=\K5      rLg)>    N)DictListOptionalUnion)NEVER_DECODEPipeline)deprecated_function   )get_protocol_version   )	to_string)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.AGGREGATE
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.SYNDUMP	NOOFFSETSNOFIELDSNOHLNOFREQSMAXTEXTFIELDS	TEMPORARY	STOPWORDSSKIPINITIALSCAN
WITHSCORESFUZZYWITHPAYLOADSc                      \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS^S jr         S_S\\   S\S\S\\\      S\\   S\S\S\4S jjrS\\\\   4   4S jrS`S\4S jjr        SaS jr SbS jr\" SSS9       ScS\S\S \S!\\   S"\S#\S$\\   S%\S\\   4S& jj5       r\" SSS9SdS' j5       r\" SS(S9SeS) j5       rS* r\" SS(S9S+ 5       r S, r!S-\\"\\\\#\\$4   4      4S. jr%S-\\"\\\\#\\$4   4      4S/ jr& SfS0\\\'4   S-\\"\\\\#\\$4   4   S4   4S1 jjr( SfS0\\\'4   S-\\"\\\\#\\$4   4      4S2 jjr)S0\\\'4   4S3 jr* SfS0\\+\,4   S-\\"\\\\#\\$4   4      4S4 jjr-S5\S0\\+\,4   S6\4S7 jr.  SgS0\\'\+4   S8\S-\\"\\\\#\\$4   4      4S9 jjr/ShS: jr0S;\S<\\   4S= jr1S;\S<\\   4S> jr2S;\4S? jr3\" S@SAS9SB\SC\SD\4SE j5       r4\" S@SFS9SB\SD\4SG j5       r5SH\4SI jr6SJ\4SK jr7SJ\4SL jr8SJ\4SM jr9SN r:SO\SD\#4SP jr;SO\SQ\SD\#4SR jr<    SiSO\SS\ST\SU\#SV\SW\SD\\=   4SX jjr>S`SY\SZ\S<\\   4S[ jjr?S\ r@S]rAg)jSearchCommands@   zSearch commands.c                     [        U R                  5      S;   a  US:X  a  [        U5      $ U$ U R                  U   " U40 UD6$ )N3   r   )r   clientr   _RESP2_MODULE_CALLBACKS)selfcmdreskwargss       X/home/james-whalen/.local/lib/python3.13/site-packages/redis/commands/search/commands.py_parse_resultsSearchCommands._parse_resultsC   sF    ,8.1\.A%c*JsJ//4SCFCC    c                 J    [        [        U5      n[        [        X35      5      $ N)mapr   dictzip)r.   r0   r1   its       r2   _parse_infoSearchCommands._parse_infoI   s    C CK  r5   c           	          [        UUS   R                  (       + US   US   R                  US   R                  US   R                  S9$ )Nqueryduration)r@   has_payloadwith_scoresfield_encodings)r   _no_content_with_payloads_with_scores_return_fields_decode_asr.   r0   r1   s      r2   _parse_searchSearchCommands._parse_searchM   sQ    w+++J'w66w44"7ODD
 	
r5   c                 2    U R                  XS   US   5      $ )Nr?   
has_cursor)_get_aggregate_resultrH   s      r2   _parse_aggregateSearchCommands._parse_aggregateW   s    ))#g|@TUUr5   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$ )Nr?   r   r@   )r@   rA   rB   r   )	
isinstancer   rM   _cursorr   rD   rE   rF   r   )r.   r0   r1   r?   results        r2   _parse_profileSearchCommands._parse_profileZ   s    we-..//A}}MFA%%%
+!00!..F )#a&111r5   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   r+   r
   r   )score
suggestion)rQ   intlen)r.   r0   r1   corrections_correction_items         r2   _parse_spellcheck SearchCommands._parse_spellchecki   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.   r0   r1   kvss       r2   _parse_config_get 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   )rangerZ   )r.   r0   r1   is       r2   _parse_syndumpSearchCommands._parse_syndump   s6    ,1!SXq,AB,AqAE
",ABBBs   0c                      U R                  XS9$ )zD
Create a new batch indexer from the client with a given chunk size
)
chunk_size)BatchIndexer)r.   rk   s     r2   batch_indexerSearchCommands.batch_indexer   s        ==r5   N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r7   
redis_args.0fs     r2   	<genexpr>.SearchCommands.create_index.<locals>.<genexpr>        *J6a<<>>6   )
CREATE_CMD
index_nameargsappendr   rQ   rY   r   r   r   r   r   r!   listtuplesetr    rZ   	itertoolschain	TypeErrorr{   execute_command)r.   ro   rp   rq   rr   rs   max_text_fields	temporaryrt   ru   rv   r   s               r2   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>`_.
rx   ADDc              3   @   #    U  H  oR                  5       v   M     g 7fr7   rz   r|   s     r2   r   2SearchCommands.alter_schema_add.<locals>.<genexpr>   r   r   )	ALTER_CMDr   r   r   r   r   r{   r   )r.   ro   r   s      r2   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_CMDr   rQ   boolr   r   )r.   r   r   
delete_strs       r2   	dropindexSearchCommands.dropindex   sY     t/ *D116F$6N  	 KK
###T**r5   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_CMDr   r   r   r   r   itemsr   )r.   doc_idconnnosaverW   payloadreplacepartiallanguage	no_createro   r   s               r2   _add_documentSearchCommands._add_document  s    " iG&8KK!KK	"KK KK	"I&J'Z**DHY__flln566''..##T**r5   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_CMDr   r   r   )r.   r   r   rW   r   r   r   s          r2   _add_document_hash!SearchCommands._add_document_hash7  s]     T__f<KK	"Z**D''..##T**r5   z2.0.0z2deprecated since redisearch 2.0, call hset insteadversionreasonr   r   rW   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 shoule be encoded as strings of "lon,lat"
N)r   r   rW   r   r   r   r   r   )r   )
r.   r   r   rW   r   r   r   r   r   ro   s
             r2   add_documentSearchCommands.add_documentK  sB    V !!

 
 	
r5   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   rW   r   r   )r   )r.   r   rW   r   r   s        r2   add_document_hash SearchCommands.add_document_hash  s%      &&Uw ' 
 	
r5   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
r   )DEL_CMDr   r   r   )r.   r   r   delete_actual_documentr   s        r2   delete_documentSearchCommands.delete_document  sK     &1!KK''..##T**r5   c                     U R                   R                  U5      nUR                  5        VVs0 s H  u  p4[        U5      [        U5      _M     nnnU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
idra   r,   hgetallr   r   KeyErrorr   r.   r   ro   kvf2s         r2   load_documentSearchCommands.load_document  s     $$R(5;\\^D^TQilIaL(^D	t (2((( E
  		s   !A&A, ,
A98A9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.

)r   MGET_CMDr   )r.   idss     r2   getSearchCommands.get  s      ##HdooDDDr5   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>`_.
r   INFO_CMDr   r3   r.   r0   s     r2   infoSearchCommands.info  s-     ""8T__=""8S11r5   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
   )rZ   r   r   )r.   r   r   keyvalues        r2   get_params_argsSearchCommands.get_params_args  sw     I|q KK!KKL)A-.*002
C E" 3 r5   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 )r   rQ   strr   
ValueErrortypeget_argsr   )r.   r?   r   r   s       r2   _mk_query_argsSearchCommands._mk_query_args  ss      eS!!%LE%''tE{m<==  $$\22{r5   r?   c                 T   U R                  XS9u  p1[        R                  " 5       n0 n[        U R                  5      S;  a	  SU[
        '   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   r)   T     @@r?   r@   r   time	monotonicr   r,   r   r   
SEARCH_CMDrQ   r   r3   r.   r?   r   r   stoptionsr0   s          r2   searchSearchCommands.search  s      ))%)K^^,H<$(GL!"":@@@c8$$J""DNN4Dr4IV3S # 
 	
r5   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   r   EXPLAIN_CMD)r.   r?   r   r   
query_texts        r2   explainSearchCommands.explain  s0      ..u.P##K7$77r5   c                     [        S5      e)Nz#EXPLAINCLI will not be implemented.)NotImplementedError)r.   r?   s     r2   explain_cliSearchCommands.explain_cli  s    !"GHHr5   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 queryr?   rL   rQ   r   r   rR   AGGREGATE_CMDr   
build_argsr   
CURSOR_CMDr   r   r   r3   r.   r?   r   rL   r/   raws         r2   	aggregateSearchCommands.aggregate  s    " e-..emm,J $//2U5E5E5GGCv&&Jvt7%:J:J:LLC[%00##L11""C(""3
 # 
 	
r5   r  rL   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
   )rQ   r   cidr   _with_schemar   )r.   r  r?   rL   cursorschemarowss          r2   rM   $SearchCommands._get_aggregate_result?  s     %((F	Aa&CFe-..53E3EVFqr7DFqr7DtV44r5   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.

r   LIMITEDQUERY	AGGREGATEr
   SEARCHz5Must provide AggregateRequest object or Query object.r   r   )r   r   PROFILE_CMDr   r   rQ   r   r  r   r   r   r   r   r3   )r.   r?   r  r   r   r/   r0   s          r2   profileSearchCommands.profileU  s    $ ^^DOOR0JJy!

7e-.. CF##%%Cu%%CF>>##C''55CTUU""C(""T^^5E5Jf4T # 
 	
r5   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SPELLCHECK_CMDr   extendr   r3   r.   r?   distanceincludeexcluder/   r0   s          r2   
spellcheckSearchCommands.spellcheck}  sw     t6JJ
H-.JJG45JJG45""C("">377r5   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)  r   r.   r0  r1  r/   s       r2   dict_addSearchCommands.dict_add  +     T"

5##S))r5   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)  r   r4  s       r2   dict_delSearchCommands.dict_del  r7  r5   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_CMDr   )r.   r0  r/   s      r2   	dict_dumpSearchCommands.dict_dump  s     d###S))r5   8.0.0Ddeprecated since Redis 8.0, call config_set from core module insteadoptionr   returnc                 <    [         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
CONFIG_CMDr   r.   rB  r   r/   r  s        r2   
config_setSearchCommands.config_set  s*     5&0""C(d{r5   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rI  r   r3   r.   rB  r/   r0   s       r2   
config_getSearchCommands.config_get  s3     5&)""C("":s33r5   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>`_.
)r   TAGVALS_CMDr   )r.   rU  s     r2   tagvalsSearchCommands.tagvals  s     ##K(KKr5   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>`_.
)r   ALIAS_ADD_CMDr   r.   rZ  s     r2   aliasaddSearchCommands.aliasadd  s     ##M5//JJr5   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>`_.
)r   ALIAS_UPDATE_CMDr   r]  s     r2   aliasupdateSearchCommands.aliasupdate  s     ##$4e__MMr5   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>`_.
)r   ALIAS_DEL_CMDr]  s     r2   aliasdelSearchCommands.aliasdel  s     ##M599r5   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stringrW   r   r   r   r   executer.   r   suggestionsr1   pipesugr   s          r2   sugaddSearchCommands.sugadd  s     }}}/C"CSYY?Dzz+&&F#{{I&CKK(  $'  ||~b!!r5   r   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>`_.
)r   SUGLEN_COMMAND)r.   r   s     r2   suglenSearchCommands.suglen.  s     ##NC88r5   rq  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>`_.
)r   SUGDEL_COMMAND)r.   r   rq  s      r2   sugdelSearchCommands.sugdel6  s     ##NC@@r5   prefixfuzzynumrB   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$   r   r   )r.   r   r  r  r  rB   r  r   r0   resultsparserss               r2   suggetSearchCommands.sugget?  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_CMDr   r)  r   )r.   r  r  r1  r/   s        r2   	synupdateSearchCommands.synupdatew  sD    $ doow7JJ)*+

5##S))r5   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>`_.
)r   SYNDUMP_CMDr   r3   r   s     r2   syndumpSearchCommands.syndump  s-     "";@"";44r5   ra   )d   )	FFNNFNFFF)F)NF      ?NFFNF)Nr  NF)Fr  NFFNF)r  NF)NFr7   )FNNNNF
   FF)B__name__
__module____qualname____firstlineno____doc__r3   r<   rI   rN   rT   r^   rc   rh   rm   r   r   r   r   r   r   r   r   r   r   r   r   r	   floatr   r   r   r   r   r   r   rY   bytesr   r   r   r   r   r  r   r   r  rM   r   r.  r5  r:  r>  rK  rS  rX  r^  rb  rf  rw  r{  r  r   r  r  r  __static_attributes__ra   r5   r2   r&   r&   @   s[   D!
V2#J>C> !&$)-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+&) 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 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	&
P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
5r5   r&   c                   8   \ rS rSrS r SS\\\4   S\\	\\\\
\\4   4      4S jj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 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     r2   r   AsyncSearchCommands.info  s9      ((4??CC""8S11 Ds   $AAANr?   r   c                 p  #    U R                  XS9u  p1[        R                  " 5       n0 n[        U R                  5      S;  a	  SU[
        '   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   r)   TNr   r   r   r   s          r2   r   AsyncSearchCommands.search  s       ))%)K^^,H<$(GL!((FdFgFFc8$$J""DNN4Dr4IV3S # 
 	
 Gs   A(B6*B4+A
B6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         r2   r  AsyncSearchCommands.aggregate  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          r2   r.  AsyncSearchCommands.spellcheck  s      t6JJ
H-.JJG45JJG45((#.."">377 /s   A6B8B9Br@  rA  r   rB  r   rC  c                 X   #    [         SX/nU R                  " U6 I Sh  vN nUS:H  $  N	7f)rE  rF  NrG  rH  rJ  s        r2   rK  AsyncSearchCommands.config_set  s5      5&0((#..d{ /s   *(
*rM  c                 ~   #    [         SU/n0 nU R                  " U6 I Sh  vN nU R                  [         U5      $  N7f)rO  rP  NrQ  rR  s       r2   rS  AsyncSearchCommands.config_get  sC      5&)((#.."":s33 /s   =;=c                   #    U R                   R                  U5      I Sh  vN nUR                  5        VVs0 s H  u  p4[        U5      [        U5      _M     nnnUn US	 [        SSU0UD6$  NNs  snnf ! [         a     N!f = f7f)r   Nr   ra   r   r   s         r2   r   !AsyncSearchCommands.load_document(  s      {{**2..5;\\^D^TQilIaL(^D	t (2((( /D
  		sD   BA0B!A2B A8 #B2B8
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>`_.
Fri  rk  rl  r   Nrm  rn  rs  s          r2   rw  AsyncSearchCommands.sugadd7  s      }}}/C"CSYY?Dzz+&&F#{{I&CKK(  $'  lln$b))$s   B<C>C?Cr   r  r  r  rB   r  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)r  r  Nr  )r.   r   r  r  r  rB   r  r   retr  r  r  s               r2   r  AsyncSearchCommands.suggetN  s     P UC8KKKK
#KK%(($//N!+cB!"6a6"" 0 #s$   A1B(3B!4B(B#B(#B(ra   r7   r  r  )r  r  r  r  r   r   r   r   r   r   rY   r  r  r   r   r   r  r.  r	   r   rK  rS  r   rw  r   r   r  r  ra   r5   r2   r  r    sd   	2 LP
S%Z 
 tCsC/E)F$FGH
F LP
_f,-
 tCsC/E)F$FGH
@88 Us 3 4 	 U4s 4s 4	4)*6 !#6#6# 6# 	6#
 6# 6# 6# 
	6# 6#r5   r  )Mr   r   typingr   r   r   r   redis.clientr   r   redis.utilsr	   helpersr   _utilr   aggregationr   r   r   documentr   fieldr   index_definitionr   profile_informationr   r?   r   rS   r   rX   r   r   r   r   r   r   r   r   r   EXPLAINCLI_CMDr   r  r  r  r(  r3  r9  r=  r   rI  rW  r\  ra  re  r   rp  r~  rz  r  r  r  r   r   r   r   r   r   r    r!   r"   r#   r$   r&   r  ra   r5   r2   <module>r     s!     . . / + *  B B   - 3   (

	

 

 
# 	
		#
Y5 Y5xh#. h#r5   