o
    Š¨Êh@
  ã                   @   s6   d dl mZ ddlmZ ddlmZ G dd„ dƒZdS )é    )ÚOptionalé   )Ú	to_string)ÚDocumentc                   @   s:   e Zd ZdZ				ddee fdd„Zdefd	d
„ZdS )ÚResultz[
    Represents the result of a search query, and has an array of Document
    objects
    r   FNÚfield_encodingsc              	   C   sØ  |d | _ || _g | _d}|r|d }|r|d }|r|d }|r#dnd}tdt|ƒ|ƒD ]¼}	t||	 ƒ}
|r?t||	|  ƒnd}|rG|d n|}|rSt||	d  ƒnd}i }|r¨||	|  dur¨tt||	|  ddd… ƒ}||	|  ddd… }t||ƒD ](\}}|du s‹||vr’t|ƒ||< q|| }|du rŸ|||< qt||d�||< qz|d= W n	 t	y¶   Y nw z|d |d< |d= W n	 t	yË   Y nw |rÙt
|
f||d	œ|¤Žn	t
|
fd
|i|¤Ž}| j |¡ q-dS )zõ
        - duration: the execution time of the query
        - has_payload: whether the query has payloads
        - with_scores: whether the query has scores
        - field_encodings: a dictionary of field encodings if any is provided
        r   r   é   N)ÚencodingÚidú$Újson)ÚscoreÚpayloadr   )ÚtotalÚdurationÚdocsÚrangeÚlenr   ÚfloatÚmapÚzipÚKeyErrorr   Úappend)ÚselfÚresÚ
hascontentr   Úhas_payloadÚwith_scoresr   ÚstepÚoffsetÚir
   r   Úfields_offsetr   ÚfieldsÚkeysÚvaluesÚkeyÚvaluer	   Údoc© r(   úN/var/www/html/env/lib/python3.10/site-packages/redis/commands/search/result.pyÚ__init__   sZ   


ÿ
ÿÿý×zResult.__init__Úreturnc                 C   s   d| j › d| j› d�S )NzResult{z total, docs: Ú})r   r   )r   r(   r(   r)   Ú__repr__V   s   zResult.__repr__)r   FFN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Údictr*   Ústrr-   r(   r(   r(   r)   r      s    	ù
ùIr   N)Útypingr   Ú_utilr   Údocumentr   r   r(   r(   r(   r)   Ú<module>   s    