o
    -i                     @   sz   d dl mZ d dlmZ G dd dZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZ	dS )    )List)	DataErrorc                   @   sl   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dZdd Zdd Zd
S )FieldNUMERICTEXTWEIGHTGEOTAGVECTORSORTABLENOINDEXASNFnameargssortableno_indexas_namec                 C   sb   |d u rg }|| _ || _t | _|| _|r| jtj |r%| jtj |r-|s/t	dd S d S )Nz-Non-Sortable non-Indexable fields are ignored)
r   r   listargs_suffixr   appendr   r   r   
ValueError)selfr   r   r   r   r    r   V/var/www/html/philips/venv/lib/python3.10/site-packages/redis/commands/search/field.py__init__   s   zField.__init__c                 C   s   | j | d S N)r   r   )r   valuer   r   r   
append_arg(   s   zField.append_argc                 C   s6   | j g}| jr|| j| jg7 }|| j7 }|| j7 }|S r   )r   r   r   r   r   )r   r   r   r   r   
redis_args+   s   

zField.redis_args)NFFN)__name__
__module____qualname__r   r   r   r   r	   r
   r   r   r   strr   boolr   r   r   r   r   r   r   r      s6    
r   c                   @   s@   e Zd ZdZdZdZ				ddeded	ed
edef
ddZ	dS )	TextFieldzI
    TextField is used to define a text field in a schema definition
    NOSTEMPHONETIC      ?FNr   weightno_stemphonetic_matcherwithsuffixtriec                 K   sr   t j| |fdt jt j|gi| |rt | | j |r-|dv r-t | | j t | | |r7t | d d S d S )Nr   )zdm:enzdm:frzdm:ptzdm:esWITHSUFFIXTRIE)r   r   r   r   r   r%   r&   )r   r   r(   r)   r*   r+   kwargsr   r   r   r   <   s   "	zTextField.__init__)r'   FNF)
r   r    r!   __doc__r%   r&   r"   floatr#   r   r   r   r   r   r$   4   s&    r$   c                   @      e Zd ZdZdefddZdS )NumericFieldzO
    NumericField is used to define a numeric field in a schema definition
    r   c                 K       t j| |fdt jgi| d S Nr   )r   r   r   r   r   r-   r   r   r   r   Z       zNumericField.__init__Nr   r    r!   r.   r"   r   r   r   r   r   r1   U       r1   c                   @   r0   )GeoFieldzP
    GeoField is used to define a geo-indexing field in a schema definition
    r   c                 K   r2   r3   )r   r   r   r4   r   r   r   r   c   r5   zGeoField.__init__Nr6   r   r   r   r   r8   ^   r7   r8   c                	   @   s:   e Zd ZdZdZdZ			ddededed	efd
dZdS )TagFieldzx
    TagField is a tag-indexing field with simpler compression and tokenization.
    See http://redisearch.io/Tags/
    	SEPARATORCASESENSITIVE,Fr   	separatorcase_sensitiver+   c                 K   sH   t j| j|g}|r|| j |r|d t j| |fd|i| d S )Nr,   r   )r   r	   r:   r   r;   r   )r   r   r=   r>   r+   r-   r   r   r   r   r   p   s   
zTagField.__init__N)r<   FF)	r   r    r!   r.   r:   r;   r"   r#   r   r   r   r   r   r9   g   s     r9   c                   @   s&   e Zd ZdZdededefddZdS )VectorFieldz
    Allows vector similarity queries against the value in this attribute.
    See https://oss.redis.com/redisearch/Vectors/#vector_fields.
    r   	algorithm
attributesc           
      K   s   | dd}| dd}|s|rtd| dvrtdg }| D ]\}}	|||	g q$tj| |fdtj|t|g|i| dS )	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   r@   rA   r-   sortnoindexattr_likeyr   r   r   r   r      s$   
zVectorField.__init__N)r   r    r!   r.   r"   dictr   r   r   r   r   r?      s    r?   N)
typingr   redisr   r   r$   r1   r8   r9   r?   r   r   r   r   <module>   s    .!		