
    h;                         d dl mZ d dlmZ  G d d      Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z	 G d de      Z
y)    )List)	DataErrorc                   l    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
Z	 	 	 	 ddedee   dededef
dZd Zd Zy)FieldNUMERICTEXTWEIGHTGEOTAGVECTORSORTABLENOINDEXASGEOSHAPENnameargssortableno_indexas_namec                     |g }|| _         || _        t               | _        || _        |r)| j                  j                  t        j                         |r)| j                  j                  t        j                         |r|st        d      y y )Nz-Non-Sortable non-Indexable fields are ignored)
r   r   listargs_suffixr   appendr   r   r   
ValueError)selfr   r   r   r   r   s         f/var/www/html/retail-simulation-api/retail/lib/python3.12/site-packages/redis/commands/search/field.py__init__zField.__init__   s{     <D		6##ENN3##EMM2HLMM %8    c                 :    | j                   j                  |       y N)r   r   )r   values     r   
append_argzField.append_arg)   s    		r   c                     | j                   g}| j                  r|| j                  | j                  gz  }|| j                  z  }|| j                  z  }|S r    )r   r   r   r   r   )r   r   s     r   
redis_argszField.redis_args,   sN    		{<<TWWdll++D		   r   )NFFN)__name__
__module____qualname__r   r   r	   r
   r   r   r   r   r   r   strr   boolr   r"   r$    r   r   r   r      s    GDF
C
CFHG	BH
 NN 3iN 	N
 N N. r   r   c                   >    e Zd ZdZdZdZ	 	 	 	 ddedededed	ef
d
Z	y)	TextFieldzI
    TextField is used to define a text field in a schema definition
    NOSTEMPHONETICNr   weightno_stemphonetic_matcherwithsuffixtriec                 b   t        j                  | |fdt         j                  t         j                  |gi| |r t         j	                  | | j
                         |r:|dv r6t         j	                  | | j                         t         j	                  | |       |rt         j	                  | d       y y )Nr   )zdm:enzdm:frzdm:ptzdm:esWITHSUFFIXTRIE)r   r   r   r	   r"   r-   r.   )r   r   r/   r0   r1   r2   kwargss          r   r   zTextField.__init__=   s     	tTUU\\6(JUfUT4;;/ 0 5
 !
 T4==1T#34T#34 r   )g      ?FNF)
r%   r&   r'   __doc__r-   r.   r(   floatr)   r   r*   r   r   r,   r,   5   sV     FH
  $$55 5 	5
 5 5r   r,   c                       e Zd ZdZdefdZy)NumericFieldzO
    NumericField is used to define a numeric field in a schema definition
    r   c                 T    t        j                  | |fdt         j                  gi| y Nr   )r   r   r   r   r   r5   s      r   r   zNumericField.__init__[   s     tTBB6Br   Nr%   r&   r'   r6   r(   r   r*   r   r   r9   r9   V   s    CS Cr   r9   c                   &    e Zd ZdZdZdZddefdZy)GeoShapeFieldzK
    GeoShapeField is used to enable within/contain indexing/searching
    	SPHERICALFLATNr   c                 ~    t         j                  g}|r|j                  |       t        j                  | |fd|i| y r;   )r   r   r   r   )r   r   coord_systemr5   r   s        r   r   zGeoShapeField.__init__g   s5    KK%tT777r   r    )r%   r&   r'   r6   r@   rA   r(   r   r*   r   r   r?   r?   _   s     ID8S 8r   r?   c                       e Zd ZdZdefdZy)GeoFieldzP
    GeoField is used to define a geo-indexing field in a schema definition
    r   c                 T    t        j                  | |fdt         j                  gi| y r;   )r   r   r
   r<   s      r   r   zGeoField.__init__s   s     tT>>v>r   Nr=   r*   r   r   rE   rE   n   s    ?S ?r   rE   c            	       8    e Zd ZdZdZdZ	 	 	 d
dedededefdZy	)TagFieldzx
    TagField is a tag-indexing field with simpler compression and tokenization.
    See http://redisearch.io/Tags/
    	SEPARATORCASESENSITIVEr   	separatorcase_sensitiver2   c                     t         j                  | j                  |g}|r|j                  | j                         |r|j                  d       t        j
                  | |fd|i| y )Nr4   r   )r   r   rI   r   rJ   r   )r   r   rK   rL   r2   r5   r   s          r   r   zTagField.__init__   sU     		4>>95KK**+KK()tT777r   N),FF)	r%   r&   r'   r6   rI   rJ   r(   r)   r   r*   r   r   rH   rH   w   sI    
 I#M
 $$88 8 	8
 8r   rH   c                   $    e Zd ZdZdededefdZy)VectorFieldz
    Allows vector similarity queries against the value in this attribute.
    See https://oss.redis.com/redisearch/Vectors/#vector_fields.
    r   	algorithm
attributesc           	      h   |j                  dd      }|j                  dd      }|s|rt        d      |j                         dvrt        d      g }|j                         D ]  \  }}	|j	                  ||	g        t        j                  | |fdt
        j                  |t        |      g|i| y)	a  
        Create Vector Field. Notice that Vector cannot have sortable or no_index tag,
        although it's also a Field.

        ``name`` is the name of the field.

        ``algorithm`` can be "FLAT" or "HNSW".

        ``attributes`` each algorithm can have specific attributes. Some of them
        are mandatory and some of them are optional. See
        https://oss.redis.com/redisearch/master/Vectors/#specific_creation_attributes_per_algorithm
        for more information.
        r   Fr   z5Cannot set 'sortable' or 'no_index' in Vector fields.)rA   HNSWzIRealtime vector indexing supporting 2 Indexing Methods:'FLAT' and 'HNSW'.r   N)	getr   upperitemsextendr   r   r   len)
r   r   rQ   rR   r5   sortnoindexattr_likeyr!   s
             r   r   zVectorField.__init__   s     zz*e,**Z/7STT??$44% 
 $**,JCNNC<( - 	$	
#llIs7|NgN	
RX	
r   N)r%   r&   r'   r6   r(   dictr   r*   r   r   rP   rP      s!    
!
S !
S !
d !
r   rP   N)typingr   redisr   r   r,   r9   r?   rE   rH   rP   r*   r   r   <module>ra      sa     , ,^5 5BC5 C8E 8?u ?8u 84'
% '
r   