
    Pf@
                     D    d dl mZ ddlmZ ddlmZ  G d d          ZdS )    )Optional   )	to_string)Documentc                   @    e Zd ZdZ	 	 	 	 d	dee         fdZdefdZdS )
Resultz[
    Represents the result of a search query, and has an array of Document
    objects
    r   FNfield_encodingsc                    |d         | _         || _        g | _        d}|r|dz   }|r|dz   }|r|dz   }|rdnd}t          dt	          |          |          D ]f}	t          ||	                   }
|rt          ||	|z                      nd}|r|dz   n|}|rt          ||	dz                      nd}i }|r||	|z            t          t
          ||	|z            ddd                   }||	|z            ddd         }t          ||          D ]B\  }}|||vrt          |          ||<   ||         }||||<   .t          ||          ||<   C	 |d= n# t          $ r Y nw xY w	 |d         |d<   |d= n# t          $ r Y nw xY w|rt          |
f||d	|nt          |
fd
|i|}| j                            |           hd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   docs                        N/var/www/html/env/lib/python3.11/site-packages/redis/commands/search/result.py__init__zResult.__init__   s     V
 	 	!8D 	!8D 	!8D!(qq#c((D)) )	" )	"A3q6""B4?IiAJ000TG*5AFQJJ6M)4>E#a!e*%%%$EF Jc!m"34@9c!m*;&<SSqS&ABBQ./15"%dF"3"3 J JJC&.#_2L2L&/&6&6s .s3H  '&+s&/&I&I&Is4LL   !'v3KK   
 =D5'DDVDDDb<<'<V<< 
 IS!!!!S)	" )	"s$   E
EE#E22
E?>E?returnc                 (    d| j          d| j         dS )NzResult{z total, docs: })r   r   )r   s    r+   __repr__zResult.__repr__V   s    A$*AADIAAAA    )r   FFN)	__name__
__module____qualname____doc__r   dictr,   strr0    r1   r+   r   r      s|          *.G" G" "$G" G" G" G"RB# B B B B B Br1   r   N)typingr   _utilr   documentr   r   r8   r1   r+   <module>r<      s                     PB PB PB PB PB PB PB PB PB PBr1   