
    +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	y)    )List)	DataErrorc                   h    e 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ASN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         N/var/www/html/venv/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   strr   boolr   r!   r#    r   r   r   r      s    GDF
C
CFHG	B
 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.   r/   r0   r1   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+   4   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   r4   s      r   r   zNumericField.__init__Z   s     tTBB6Br   Nr$   r%   r&   r5   r'   r   r)   r   r   r8   r8   U   s    CS Cr   r8   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__c   s     tT>>v>r   Nr<   r)   r   r   r>   r>   ^   s    ?S ?r   r>   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_sensitiver1   c                     t         j                  | j                  |g}|r|j                  | j                         |r|j                  d       t        j
                  | |fd|i| y )Nr3   r   )r   r   rB   r   rC   r   )r   r   rD   rE   r1   r4   r   s          r   r   zTagField.__init__p   sU     		4>>95KK**+KK()tT777r   N),FF)	r$   r%   r&   r5   rB   rC   r'   r(   r   r)   r   r   rA   rA   g   sI    
 I#M
 $$88 8 	8
 8r   rA   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.)FLATHNSWzIRealtime vector indexing supporting 2 Indexing Methods:'FLAT' and 'HNSW'.r   N)	getr   upperitemsextendr   r   r   len)
r   r   rJ   rK   r4   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&   r5   r'   dictr   r)   r   r   rI   rI      s!    
!
S !
S !
d !
r   rI   N)
typingr   redisr   r   r+   r8   r>   rA   rI   r)   r   r   <module>r[      sU     + +\5 5BC5 C?u ?8u 84'
% '
r   