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