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) 

相关内容

热门资讯

玩家攻略!拱趴大菠萝挂,soh... 玩家攻略!拱趴大菠萝挂,sohoo poker辅助器,揭幕教程(有挂神器)-哔哩哔哩1、sohoo ...
来临!乐驿茶坊辅助器下载!确实... 来临!乐驿茶坊辅助器下载!确实真的有辅助插件(存在有挂)-哔哩哔哩1、该软件可以轻松地帮助玩家将乐驿...
有消息称!wepoker私人局... 有消息称!wepoker私人局俱乐部(透视)辅助神器(果真有挂)-哔哩哔哩1)wepoker私人局俱...
总算了解!hhpoker怎么开... 总算了解!hhpoker怎么开透视(透视)辅助安装(都是真的有挂)-哔哩哔哩透视方法中分为三种模型:...
科普!哈糖大菠萝怎么挂,wep... 科普!哈糖大菠萝怎么挂,wepoker辅助器安装包,开挂教程(有挂透明挂)-哔哩哔哩wepoker辅...
近期!新二号辅助软件怎么下载!... 近期!新二号辅助软件怎么下载!一直存在有辅助器(有挂功能)-哔哩哔哩1、每一步都需要思考,不同水平的...
于此同时!uupoker有透视... 于此同时!uupoker有透视吗(透视)辅助修改器(有挂辅助)-哔哩哔哩1)uupoker有透视吗有...
据了解!aapoker万能辅助... 据了解!aapoker万能辅助器(透视)辅助工具(原来是有挂)-哔哩哔哩1、破解器简单,机器人操作,...
安装程序教程!xpoker辅助... 安装程序教程!xpoker辅助工具,pokemmo辅助器手机版下载,总结教程(有挂分析)-哔哩哔哩一...
据通报!逍遥辅助官网!本来真的... 据通报!逍遥辅助官网!本来真的有辅助脚本(有挂秘诀)-哔哩哔哩1)逍遥辅助官网免费钻石:进一步探索逍...