
    j!                         d dl Z d dlmZmZmZ d dlmZmZ d dlm	Z	  ed          Z
 ed          Z G d d          Z
dS )    N)DictOptionalTypeVar)CollectionNotExistExceptionExceptionsMessage)ConfigIndex
Collectionc                       e Zd ZdedededefdZd Ze	de
fd            Ze	defd            Ze	defd	            Ze	defd
            ZdedefdZd Zddee         fdZdS )r	   
collection
field_nameindex_paramsreturnc                     ddl m} t          ||          st          t          j                  || _        || _        || _        |	                    dt          j                  | _        |	                    dd          rdS |                                 } |j        | j        j        | j        | j        fi | |                    | j        j                  }|D ]!}|j        | j        k    r|j        | _         dS "dS )a  Creates index on a specified field according to the index parameters.

        Args:
            collection(Collection): The collection in which the index is created
            field_name(str): The name of the field to create an index for.
            index_params(dict): Indexing parameters.
            kwargs:
                * *index_name* (``str``) --
                  The name of index which will be created. If no index name is specified,
                  default index name will be used.

        Raises:
            MilvusException: If anything goes wrong.

        Examples:
            >>> from pymilvus import *
            >>> from pymilvus.schema import *
            >>> from pymilvus.types import DataType
            >>> connections.connect()
            <pymilvus.client.stub.Milvus object at 0x7fac15e53470>
            >>> field1 = FieldSchema("int64", DataType.INT64, is_primary=True)
            >>> field2 = FieldSchema("fvec", DataType.FLOAT_VECTOR, is_primary=False, dim=128)
            >>> schema = CollectionSchema(fields=[field1, field2])
            >>> collection = Collection(name='test_collection', schema=schema)
            >>> # insert some data
            >>> index_params = {
            ...     "index_type": "IVF_FLAT",
            ...     "metric_type": "L2",
            ...     "params": {"nlist": 128}}
            >>> index = Index(collection, "fvec", index_params)
            >>> index.params
            {'index_type': 'IVF_FLAT', 'metric_type': 'L2', 'params': {'nlist': 128}}
            >>> index.collection_name
            test_collection
            >>> index.field_name
            fvec
            >>> index.drop()
           )r
   )message
index_nameconstruct_onlyFN)r   r
   
isinstancer   r   CollectionType_collection_field_name_index_paramsgetr   	IndexName_index_name_get_connectioncreate_indexnamelist_indexesr   r   )	selfr   r   r   kwargsr
   connindexesindexs	            \/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/pymilvus/orm/index.py__init__zIndex.__init__   s#   Z 	+******j11 	X-6G6VWWWW%%)!::lF4DEE::&.. 	F##%%$*/1A4CU``Y_```##D$4$9:: 	 	E4#333#(#3  4	 	    c                 4    | j                                         S N)r   r   r!   s    r&   r   zIndex._get_connectionX   s    //111r(   c                 4    t          j        | j                  S )zdict: The index parameters)copydeepcopyr   r+   s    r&   paramszIndex.params[   s     }T/000r(   c                     | j         j        S )z&str: The corresponding collection name)r   r   r+   s    r&   collection_namezIndex.collection_name`   s     $$r(   c                     | j         S )z"str: The corresponding field name.)r   r+   s    r&   r   zIndex.field_namee        r(   c                     | j         S )z"str: The corresponding index name.)r   r+   s    r&   r   zIndex.index_namej   r3   r(   otherc                 V    |                                  |                                 k    S )z4The order of the fields of index must be consistent.)to_dict)r!   r5   s     r&   __eq__zIndex.__eq__o   s    ||~~00r(   c                 B    | j         j        | j        | j        | j        dS )z;Put collection name, field name and index params into dict.)r   fieldr   index_param)r   _namer   r   r/   r+   s    r&   r7   zIndex.to_dicts   s-     *0%*;	
 
 	
r(   Ntimeoutc                     |                                  }|                    | j        j        | j        | j        |           dS )a  Drop an index and its corresponding index files.

        Args:
            timeout(float, optional): An optional duration of time in seconds to allow
                for the RPC. When timeout is set to None, client waits until server response
                or error occur
        )r1   r   r   r=   N)r   
drop_indexr   r   r   r   )r!   r=   r"   r#   s       r&   dropz
Index.drop|   sP     ##%% ,1	 	 	
 	
 	
 	
 	
r(   r*   )__name__
__module____qualname__r
   strr   r	   r'   r   propertydictr/   r1   r   r   boolr8   r7   r   floatr@    r(   r&   r	   r	      sO       >> > 	> 
> > > >@2 2 2 1 1 1 1 X1 % % % % X%  C       X   C       X 1E 1d 1 1 1 1
 
 

 
HUO 
 
 
 
 
 
r(   )r-   typingr   r   r   pymilvus.exceptionsr   r   pymilvus.settingsr   r	   r
   rI   r(   r&   <module>rM      s     * * * * * * * * * * N N N N N N N N $ $ $ $ $ $W\""
s
 s
 s
 s
 s
 s
 s
 s
 s
 s
r(   