
    ng\j_                          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
Jr  SSK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)    )Literal)Pipeline   )check_protocol_version   )get_legacy_responsesget_protocol_version   )AGGREGATE_CMD
CURSOR_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      Y/home/edenadmin/noVNC/venv/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/   r0   r1   r2   r3   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/   r1   r
   N)r   _add_document_hashr   r   r   r   r'   )r    r7   r/   r1   s       r!   add_document_hash%Search.BatchIndexer.add_document_hashF   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.commitR   s     NN""$!"Dr$   )r   r   r   r   r   r   )i  F      ?NFFF)rE   F)__name__
__module____qualname____firstlineno____doc__r"   r)   r9   r=   r'   __static_attributes__ r$   r!   BatchIndexerr      s4    	
	#	 	<
		#r$   rM   c                     Xl         X l        UR                  U l        UR                  U l        U R                  5         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)r   
index_namer   r   r   _init_module_callbacks)r    r   rO   s      r!   r"   Search.__init__Y   s3     $%55##%r$   Nc                     [        U R                  R                  U R                  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   rT   rU   rO   r    r   r   ps       r!   r   Search.pipelinef   s@      KK77#{{==#!	
 r$   )r   r   r   rO   )idxTN)	rF   rG   rH   rI   rJ   rM   r"   r   rK   rL   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)AsyncSearcht   c                   4    \ rS rSrSr      SS jrS rSrg)AsyncSearch.BatchIndexeru   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,   r4   r6   s	            r!   r9   %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   rA   r(   s    r!   r'   AsyncSearch.BatchIndexer.commit   s*      ..((***!"D +s   /-/)r   rD   )rF   rG   rH   rI   rJ   r9   r'   rK   rL   r$   r!   rM   r_   u   s%    	 	$<	#r$   rM   Nc                     [        U R                  R                  U R                  R                  UUS9nU R                  Ul        U$ rS   )AsyncPipeliner   rT   rU   rO   rV   s       r!   r   AsyncSearch.pipeline   s@      KK77#{{==#!	
 r$   rL   rZ   )rF   rG   rH   rI   r   rM   r   rK   rL   r$   r!   r\   r\   t   s    )#v** )#Vr$   r\   c                   X   ^  \ rS rSr% SrSr\S   \S'   U 4S jrS r	\
S 5       rSrU =r$ )	r      zPipeline for the module.F_is_async_clientc                 z   > [         TU ]  U[        U5      X45        U R                  5         U R	                  5         g r&   superr"   dictrP   _register_module_callbacksr    rT   rU   r   r   	__class__s        r!   r"   Pipeline.__init__   9     	T"45{	
 	##%'')r$   c                    [        U 5      n[        U 5      (       a1  Uc  U R                  nOK[        US5      (       a  U R                  nO-0 nO*[        US5      (       a  U R
                  nOU R                  nUR                  5        H  u  p4X@R                  U'   M     UR                  [        5      nUb  XPR                  [        '   g g )Nr   )r	   r   )_RESP3_TO_RESP2_LEGACY_PIPELINE_CALLBACKSr   _RESP3_MODULE_CALLBACKS_RESP3_UNIFIED_MODULE_CALLBACKS_RESP2_UNIFIED_MODULE_CALLBACKSitemsrU   getr   r   )r    protocolcmd_callbackscmdcbagg_cbs         r!   ro   #Pipeline._register_module_callbacks   s     (-%% $ N N'!44 $ < < "%h22 $ D D $ D D$**,GC+-##C( - ""=128##J/ r$   c                     U $ )zAReturn self so ``get_protocol_version`` can read connection_pool.rL   r(   s    r!   r   Pipeline.client   s	     r$   rL   )rF   rG   rH   rI   rJ   rj   r   __annotations__r"   ro   propertyr   rK   __classcell__rq   s   @r!   r   r      s3    "',gen,*98  r$   r   c                   R   ^  \ rS rSr% SrSr\S   \S'   U 4S jr\	S 5       r
SrU =r$ )rf      zAsyncPipeline for the module.Trj   c                 z   > [         TU ]  U[        U5      X45        U R                  5         U R	                  5         g r&   rl   rp   s        r!   r"   AsyncPipeline.__init__   rs   r$   c                     U $ )zReturn self so ``get_protocol_version`` can read connection_pool.

Redefined here because ``redis.asyncio.client.Redis.client`` (a
plain method) appears earlier in the MRO than ``Pipeline.client``
(a property) and would otherwise shadow it.
rL   r(   s    r!   r   AsyncPipeline.client   s	     r$   rL   )rF   rG   rH   rI   rJ   rj   r   r   r"   r   r   rK   r   r   s   @r!   rf   rf      s.    '&*gdm**  r$   rf   N)typingr   redis.clientr   RedisPipelineasyncio.clientAsyncioPipelineutilsr   helpersr   r	   commandsr   r   r   r   r   r\   rf   rL   r$   r!   <module>r      s]     2 9 + @ a^ aH7&- 7t-~} -`'( r$   