milvus的collection操作
创始人
2024-12-28 03:10:05
0

milvus的collection操作

创建collection

import uuid  from pymilvus import (     connections,     FieldSchema, CollectionSchema, DataType,     Collection, )  collection_name = "hello_milvus" host = "192.168.230.71" port = 19530 username = "" password = "" num_entities, dim = 5000, 3  print("start connecting to Milvus") connections.connect("default", host=host, port=port,user=username,password=password)  fields = [     FieldSchema(name="pk", dtype=DataType.INT64, is_primary=True, auto_id=False),     FieldSchema(name="random", dtype=DataType.DOUBLE),     FieldSchema(name="comment", dtype=DataType.VARCHAR, max_length=200),     FieldSchema(name="embeddings", dtype=DataType.FLOAT16_VECTOR, dim=dim) ]  schema = CollectionSchema(fields, "hello_milvus is the simplest demo to introduce the APIs")  print("Create collection `hello_world`") coll = Collection(collection_name, schema, consistency_level="Bounded",shards_num=1)  print("done") 

Collection()是一个构造函数,定义如下:

class Collection:     def __init__(         self,         name: str,         schema: Optional[CollectionSchema] = None,         using: str = "default",         **kwargs,     ) -> None: 

name – the name of collection
schema – the schema of collection, defaults to None.
using – Milvus connection alias name, defaults to ‘default’.

**kwargs - 告诉python接受任意数量的关键字参数到这个字典中。

那milvus这里有哪些key?

看注释。

在这里插入图片描述

删除collection

coll.drop() 

函数定义:

def drop(self, timeout: Optional[float] = None, **kwargs): 

有一个timeout参数。

加载collection

功能:加载collection到内存。

coll.load() 

函数定义:

def load(         self,         partition_names: Optional[list] = None,         replica_number: int = 1,         timeout: Optional[float] = None,         **kwargs,     ) 

参数说明:

在这里插入图片描述

coll.load() #阻塞 coll.load(_async=True) #非阻塞 utility.wait_for_loading_complete("hello_iterator") 

释放collection

从内存中卸载。

coll.release() 

描述collection

获取collection的信息

infos = coll.describe() for key, value in infos.items():     print(key, value) 

相关内容

热门资讯

科技透视!hhpoker到底可... 科技透视!hhpoker到底可以辅助码,打哈儿麻将小程序脚本(最新技巧辅助开挂神器);最新版2026...
传授透视!pokerworld... 传授透视!pokerworld软件,wepoker私人局外卦(附辅助开挂插件);1、超多福利:超高返...
推荐透视!智星德州插件怎么下载... 推荐透视!智星德州插件怎么下载,丰城呱呱辅助器(每日必备开挂辅助脚本);丰城呱呱辅助器中的10万兆豆...
曝光透视!wepoker网页版... 曝光透视!wepoker网页版透视方法,wepoker有辅助吗(附辅助开挂插件);1、完成wepok...
正品透视!德普辅助器怎么用,西... 正品透视!德普辅助器怎么用,西兵互娱辅助多少钱(透视挂辅助开挂脚本);AI辅助机器人普及解说快速成为...
推荐透视!hhpoker一直输... 推荐透视!hhpoker一直输有挂吗,pokerworld软件(附开挂辅助工具);1、超多福利:超高...
细节透视!德普之星透视辅助软件... 细节透视!德普之星透视辅助软件下载,八闽辅助(技术分享开挂辅助软件);小薇(透视辅助)致您一封信;亲...
关于透视!werplan怎么透... 关于透视!werplan怎么透视,wepoker有没有辅助(附辅助开挂安装);wepoker有没有辅...
详细透视!wepoker线上大... 详细透视!wepoker线上大神,wepoker免费脚本(热点讨论辅助开挂插件);小薇(透视辅助)致...
了解透视!wepoker辅助器... 了解透视!wepoker辅助器免费,wepoker有辅助工具吗(附辅助开挂安装);wepoker有辅...