
    j,g                         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                       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ZdZdZ	 	 	 	 	 	 ddedee   dededededefdZd Zd Zy)Fieldz5
    A class representing a field in a document.
    NUMERICTEXTWEIGHTGEOTAGVECTORSORTABLENOINDEXASGEOSHAPEINDEXMISSING
INDEXEMPTYNnameargssortableno_indexindex_missingindex_emptyas_namec                    |g }|| _         || _        t               | _        || _        |r)| j                  j                  t        j                         |r)| j                  j                  t        j                         |r)| j                  j                  t        j                         |r)| j                  j                  t        j                         |r|st        d      yy)aL  
        Create a new field object.

        Args:
            name: The name of the field.
            args:
            sortable: If `True`, the field will be sortable.
            no_index: If `True`, the field will not be indexed.
            index_missing: If `True`, it will be possible to search for documents that
                           have this field missing.
            index_empty: If `True`, it will be possible to search for documents that
                         have this field empty.
            as_name: If provided, this alias will be used for the field.
        Nz-Non-Sortable non-Indexable fields are ignored)r   r   listargs_suffixr   appendr   r   r   INDEX_MISSINGINDEX_EMPTY
ValueError)selfr   r   r   r   r   r   r   s           u/var/www/trellinator.diamondhoofcare.com/public_html/venv/lib/python3.12/site-packages/redis/commands/search/field.py__init__zField.__init__   s    0 <D		6##ENN3##EMM2##E$7$78##E$5$56HLMM %8    c                 :    | j                   j                  |       y N)r   r   )r!   values     r"   
append_argzField.append_argC   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_argsF   sN    		{<<TWWdll++D		   r$   )NFFFFN)__name__
__module____qualname____doc__r   r   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"MK
 #!)N)N 3i)N 	)N
 )N )N )N )NV 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(   r4   r5   )r!   r   r6   r7   r8   r9   kwargss          r"   r#   zTextField.__init__W   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-   r.   r4   r5   r/   floatr0   r#   r1   r$   r"   r3   r3   O   sV     FH
  $$55 5 	5
 5 5r$   r3   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   r<   s      r"   r#   zNumericField.__init__u   s     tTBB6Br$   Nr+   r,   r-   r.   r/   r#   r1   r$   r"   r?   r?   p   s    CS Cr$   r?   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 rA   )r   r   r   r#   )r!   r   coord_systemr<   r   s        r"   r#   zGeoShapeField.__init__   s5    KK%tT777r$   r&   )r+   r,   r-   r.   rF   rG   r/   r#   r1   r$   r"   rE   rE   y   s     ID8S 8r$   rE   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 rA   )r   r#   r
   rB   s      r"   r#   zGeoField.__init__   s     tT>>v>r$   NrC   r1   r$   r"   rK   rK      s    ?S ?r$   rK   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_sensitiver9   c                     t         j                  | j                  |g}|r|j                  | j                         |r|j                  d       t        j
                  | |fd|i| y )Nr;   r   )r   r   rO   r   rP   r#   )r!   r   rQ   rR   r9   r<   r   s          r"   r#   zTagField.__init__   sU     		4>>95KK**+KK()tT777r$   N),FF)	r+   r,   r-   r.   rO   rP   r/   r0   r#   r1   r$   r"   rN   rN      sI    
 I#M
 $$88 8 	8
 8r$   rN   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.)rG   HNSWzIRealtime vector indexing supporting 2 Indexing Methods:'FLAT' and 'HNSW'.r   N)	getr   upperitemsextendr   r#   r   len)
r!   r   rW   rX   r<   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-   r.   r/   dictr#   r1   r$   r"   rV   rV      s!    
!
S !
S !
d !
r$   rV   N)typingr   redisr   r   r3   r?   rE   rK   rN   rV   r1   r$   r"   <module>rg      sc     F FR5 5BC5 C8E 8?u ?8u 84'
% '
r$   