
    ph                         S SK Jr  SSKJr  SSKJrJrJrJ	r	J
r
JrJrJrJr   " S S\5      r " S S\\5      r " S	 S
\\5      r " S S\\\5      rg)    )Pipeline      )	AGGREGATE_CMD
CONFIG_CMDINFO_CMDPROFILE_CMD
SEARCH_CMDSPELLCHECK_CMDSYNDUMP_CMDAsyncSearchCommandsSearchCommandsc                   @    \ rS rSrSr " S S5      rS	S jrS
S jrSrg)Search   zm
Create a client for talking to search.
It abstracts the API of the module and lets you just use the engine.
c                   N    \ rS rSrSrS
S jrS r      SS jrSS jrS r	S	r
g)Search.BatchIndexer   r
A batch indexer allows you to automatically batch
document indexing in pipelines, flushing it every N documents.
c                     Xl         UR                  U l        UR                  SS S9U l        SU l        X l        SU l        g )NF)transaction
shard_hintr   )clientexecute_commandpipeline	_pipelinetotal
chunk_sizecurrent_chunk)selfr   r   s      X/home/james-whalen/.local/lib/python3.13/site-packages/redis/commands/search/__init__.py__init__Search.BatchIndexer.__init__   s=     K#)#9#9D #__4_PDNDJ(O!"D    c                 H    U R                   (       a  U R                  5         g g )N)r   commitr    s    r!   __del__Search.BatchIndexer.__del__%   s    !! "r$   Nc                    U R                   R                  " U4U R                  UUUUUUS.UD6  U =R                  S-  sl        U =R                  S-  sl        U R                  U R
                  :  a  U R                  5         ggz#
Add a document to the batch query
)connnosavescorepayloadreplacepartial	no_creater   Nr   _add_documentr   r   r   r   r&   	r    doc_idr-   r.   r/   r0   r1   r2   fieldss	            r!   add_document Search.BatchIndexer.add_document)   s     KK%%
^^#
 
 !#JJ!OJ!!T__4 5r$   c                     U R                   R                  XR                  X#S9  U =R                  S-  sl        U =R                  S-  sl        U R                  U R
                  :  a  U R                  5         gg)z
Add a hash to the batch query
)r,   r.   r0   r   N)r   _add_document_hashr   r   r   r   r&   )r    r6   r.   r0   s       r!   add_document_hash%Search.BatchIndexer.add_document_hashG   sd     KK**^^5 +  !#JJ!OJ!!T__4 5r$   c                 F    U R                   R                  5         SU l        g)4
Manually commit and flush the batch indexing query
r   Nr   executer   r'   s    r!   r&   Search.BatchIndexer.commitS   s     NN""$!"Dr$   )r   r   r   r   r   r   )i  F      ?NFFF)rD   F)__name__
__module____qualname____firstlineno____doc__r"   r(   r8   r<   r&   __static_attributes__ r$   r!   BatchIndexerr      s4    	
	#	 	<
		#r$   rL   c                 \   0 U l         Xl        X l        UR                  U l        UR                  U l        [        U R                  [        U R                  [        U R                  [        U R                  [        U R                  [         U R"                  [$        U R&                  0U l        g)z
Create a new Client for the given index_name.
The default name is `idx`

If conn is not None, we employ an already existing redis connection
N)_MODULE_CALLBACKSr   
index_namer   r   r   r   _parse_infor
   _parse_searchr   _parse_aggregater	   _parse_profiler   _parse_spellcheckr   _parse_config_getr   _parse_syndump_RESP2_MODULE_CALLBACKS)r    r   rO   s      r!   r"   Search.__init__Z   s     "$$%55d&&**400,,D22..,,(
$r$   Nc                 |    [        U R                  R                  U R                  UUS9nU R                  Ul        U$ z|Creates a pipeline for the SEARCH module, that can be used for executing
SEARCH commands, as well as classic core commands.
)connection_poolresponse_callbacksr   r   )r   r   r[   rN   rO   r    r   r   ps       r!   r   Search.pipelinep   s<      KK77#55#!	
 r$   )rN   rW   r   r   r   rO   )idxTN)	rE   rF   rG   rH   rI   rL   r"   r   rJ   rK   r$   r!   r   r      s    
A# A#F
,r$   r   c                   H    \ rS rSr " S S\R
                  5      rSS jrSrg)AsyncSearch~   c                   4    \ rS rSrSr      SS jrS rSrg)AsyncSearch.BatchIndexer   r   Nc                 (  #    U R                   R                  " U4U R                  UUUUUUS.UD6  U =R                  S-  sl        U =R                  S-  sl        U R                  U R
                  :  a  U R                  5       I Sh  vN   gg N7fr+   r3   r5   s	            r!   r8   %AsyncSearch.BatchIndexer.add_document   s      KK%%
^^#
 
 !#JJ!OJ!!T__4kkm## 5#s   BB	B
Bc                 b   #    U R                   R                  5       I Sh  vN   SU l        g N7f)r?   Nr   r@   r'   s    r!   r&   AsyncSearch.BatchIndexer.commit   s*      ..((***!"D +s   /-/)r   rC   )rE   rF   rG   rH   rI   r8   r&   rJ   rK   r$   r!   rL   rf      s%    	 	$<	#r$   rL   Nc                 |    [        U R                  R                  U R                  UUS9nU R                  Ul        U$ rZ   )AsyncPipeliner   r[   rN   rO   r]   s       r!   r   AsyncSearch.pipeline   s<      KK77#55#!	
 r$   rK   ra   )rE   rF   rG   rH   r   rL   r   rJ   rK   r$   r!   rc   rc   ~   s    )#v** )#Vr$   rc   c                       \ rS rSrSrSrg)r      zPipeline for the module.rK   NrE   rF   rG   rH   rI   rJ   rK   r$   r!   r   r      s    "r$   r   c                       \ rS rSrSrSrg)rm      zAsyncPipeline for the module.rK   Nrq   rK   r$   r!   rm   rm      s    'r$   rm   N)redis.clientr   RedisPipelineasyncio.clientAsyncioPipelinecommandsr   r   r   r	   r
   r   r   r   r   r   rc   rm   rK   r$   r!   <module>ry      sX    2 9
 
 
j^ jZ7&- 7t#~} #('( (r$   