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、让任何用户在无需...
发现一款!pokemmo免费脚... 发现一款!pokemmo免费脚本,陕麻圈黑科技,本来存在有辅助辅助(有挂神器)1、这是跨平台的pok...
来一盘!wepoker私人局俱... 来一盘!wepoker私人局俱乐部怎么进,赣牌圈有挂吗,果然真的是有辅助工具(揭秘有挂)1、全新机制...
玩家必看科普!wepoker黑... 玩家必看科普!wepoker黑侠破解,wepoker辅助器是真的吗,真是真的是有辅助插件(有挂解密)...
最新技巧!wpk辅助软件,王重... 最新技巧!wpk辅助软件,王重阳小程序辅助器,本来是真的有辅助开挂(了解有挂)1、下载好王重阳小程序...
技巧知识分享!德州局hhpok... 技巧知识分享!德州局hhpoker,中至抚州数刀辅助器,本来存在有辅助教程(有挂教程)1、点击下载安...
玩家必看攻略!哈糖大菠萝开挂,... 玩家必看攻略!哈糖大菠萝开挂,余干辅助软件哪个好,其实真的是有辅助辅助(有挂细节)1、全新机制【余干...
盘点一款!wepoker手机插... 盘点一款!wepoker手机插件,一起宁德钓蟹作必弊,一贯是真的有辅助神器(讲解有挂)1、金币登录送...
揭秘关于!德州透视竞技联盟,七... 揭秘关于!德州透视竞技联盟,七千在线十三道辅助,确实是真的有辅助开挂(有挂细节)七千在线十三道辅助透...
传递经验!购买wepoker模... 传递经验!购买wepoker模拟器,顺欣茶楼辅助软件视频,其实真的有辅助神器(新版有挂)1)顺欣茶楼...