milvus.
Milvus
(host=None, port=None, handler='GRPC', pool='SingletonThread', **kwargs)¶compact
(collection_name, timeout=None, **kwargs)¶Compacts segments in a collection. This function is recommended after deleting vectors.
collection_name (str) -- Name of the collections to compact.
count_entities
(collection_name, timeout=30)¶Returns the number of vectors in a collection.
collection_name (str) -- target table name.
Status: indicate if operation is successful
res: int, table row count
create_collection
(param, timeout=30)¶Creates a collection.
param (dict) --
Information needed to create a collection.
'dimension': 16, 'index_file_size': 1024 (default), 'metric_type': Metric_type.L2 (default) }`
timeout (double) -- Timeout in seconds.
Whether the operation is successful.
Status
create_index
(collection_name, index_type=None, params=None, timeout=None, **kwargs)¶Creates index for a collection.
collection_name (str) -- Collection used to create index.
index -- index params
timeout (int) --
grpc request timeout.
if timeout = -1, method invoke a synchronous call, waiting util grpc response else method invoke a asynchronous call, timeout work here
Whether the operation is successful.
create_partition
(collection_name, partition_tag, timeout=30)¶create a partition for a collection.
collection_name (str) -- Name of the collection.
partition_name (str) -- Name of the partition.
partition_tag (str) -- Name of the partition tag.
timeout (int) -- time waiting for response.
Status: Whether the operation is successful.
delete_entity_by_id
(collection_name, id_array, timeout=None)¶Deletes vectors in a collection by vector ID.
collection_name (str) -- Name of the collection.
id_array (list[int]) -- list of vector id
Status: Whether the operation is successful.
drop_collection
(collection_name, timeout=30)¶Deletes a collection by name.
collection_name (str) -- Name of the collection being deleted
Status, indicate if operation is successful
Status
drop_index
(collection_name, timeout=30)¶Removes an index.
collection_name (str) -- target collection name.
Status: Whether the operation is successful.
::rtype: Status
drop_partition
(collection_name, partition_tag, timeout=30)¶Deletes a partition in a collection.
collection_name (str) -- Collection name.
partition_tag (str) -- Partition name.
timeout (int) -- time waiting for response.
Status: Whether the operation is successful.
flush
(collection_name_array=None, timeout=None, **kwargs)¶Flushes vector data in one collection or multiple collections to disk.
collection_name -- Name of one or multiple collections to flush.
get_collection_info
(collection_name, timeout=30)¶Returns information of a collection.
collection_name (str) -- Name of the collection to describe.
(Status, table_schema) Status: indicate if query is successful table_schema: return when operation is successful
(Status, TableSchema)
get_collection_stats
(collection_name, timeout=30)¶Returns collection statistics information
Status: indicate if this operation is successful
statistics: statistics information
(Status, dict)
get_entity_by_id
(collection_name, ids, timeout=None)¶Returns raw vectors according to ids.
collection_name (str) -- Name of the collection
ids (list) -- list of vector id
Status: indicate if invoke is successful
has_collection
(collection_name, timeout=30)¶Checks whether a collection exists.
collection_name (str) -- Name of the collection to check.
timeout (int) -- Timeout in seconds.
Status: indicate whether the operation is successful. bool if given collection_name exists
has_partition
(collection_name, partition_tag)¶Check if specified partition exists.
collection_name (str) -- target table name.
partition_tag (str) -- partition tag.
Status: Whether the operation is successful. exists: If specified partition exists
insert
(collection_name, records, ids=None, partition_tag=None, params=None, timeout=None, **kwargs)¶Insert vectors to a collection.
ids (list[int]) -- list of id
collection_name (str) -- Name of the collection to insert vectors to.
records -- List of vectors to insert.
partition_tag (str or None. If partition_tag is None, vectors will be inserted to the collection rather than partitions.) -- Tag of a partition.
Status: Whether vectors are inserted successfully. ids: IDs of the inserted vectors.
(Status, list(int))
list_collections
(timeout=30)¶Returns collection list.
Status: indicate if this operation is successful
is successful
(Status, list[str])
list_partitions
(collection_name, timeout=30)¶Show all partitions in a collection.
collection_name (str) -- target table name.
timeout (int) -- time waiting for response.
Status: Whether the operation is successful. partition_list:
load_collection
(collection_name, partition_tags=None, timeout=None)¶Loads a collection for caching.
collection_name (str) -- collection to load
Status: indicate if invoke is successful
search
(collection_name, top_k, query_records, partition_tags=None, params=None, timeout=None, **kwargs)¶Search vectors in a collection.
collection_name (str) -- Name of the collection.
top_k (int) -- number of vertors which is most similar with query vectors
nprobe (int) -- cell number of probe
query_records (list[list[float32]]) -- vectors to query
partition_tags (list) -- tags to search
Status: Whether the operation is successful. result: query result
(Status, TopKQueryResult)
search_in_segment
(collection_name, file_ids, query_records, top_k, params=None, timeout=None, **kwargs)¶Searches for vectors in specific segments of a collection.
The Milvus server stores vector data into multiple files. Searching for vectors in specific files is a method used in Mishards. Obtain more detail about Mishards, see <a href="https://github.com/milvus-io/milvus/tree/master/shards">
collection_name (str) -- table name been queried
file_ids (list[str] or list[int]) -- Specified files id array
query_records (list[list[float]]) -- all vectors going to be queried
query_ranges --
Optional ranges for conditional search.
If not specified, search in the whole table
top_k (int) -- how many similar vectors will be searched
Status: indicate if query is successful results: query result
(Status, TopKQueryResult)