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) 

相关内容

热门资讯

外挂方案!竞技联盟破解版最新版... 外挂方案!竞技联盟破解版最新版,德州透视竞技联盟-一贯存在有辅助脚本(哔哩哔哩)1、上手简单,内置详...
透视科技!德扑HHpoker有... 透视科技!德扑HHpoker有挂吗(透视)确实真的是有辅助辅助器(有挂详细)-哔哩哔哩1、实时德扑H...
专业讨论!wpk可以作必弊吗,... 专业讨论!wpk可以作必弊吗,鄱阳翻精怎么开挂,本来有辅助神器(有挂规律)进入游戏-大厅左侧-新手福...
外挂指南书!智星菠萝德州插件最... 外挂指南书!智星菠萝德州插件最新版本更新内容详解,拱趴大菠萝机器人-原来一直总是有辅助工具(哔哩哔哩...
连日来!pokemmo辅助器脚... 连日来!pokemmo辅助器脚本下载(透视)原来是真的辅助软件(有挂透明挂)-哔哩哔哩1、不需要AI...
分享一款!hhpoker作必弊... 分享一款!hhpoker作必弊码,衢州都莱罗松怎么才能赢,一直存在有辅助脚本(存在有挂)1、任何衢州...
截至发稿!uupoker有透视... 截至发稿!uupoker有透视吗(透视)果然存在有辅助平台(发现有挂)-哔哩哔哩1、每一步都需要思考...
外挂演示!德普之星透视辅助软件... 外挂演示!德普之星透视辅助软件激活码,德普之星透视辅助软件激活码-果然一直总是有辅助工具(哔哩哔哩)...
玩家攻略!wepoker安装教... 玩家攻略!wepoker安装教程,决战十三水ios辅助,真是是有辅助下载(有挂解密)1、下载好决战十...
刚刚!wepoker怎么开辅助... 刚刚!wepoker怎么开辅助(透视)好像真的有辅助修改器(有挂规律)-哔哩哔哩;1、首先打开wep...