o
    `f@
                     @   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rtt||	|  ddd }||	|  ddd }t||D ](\}}|du s||vrt|||< 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 |rt
|
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(   U/home/ubuntu/webapp/venv/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    