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) 

相关内容

热门资讯

有了最新消息!uupoker有... 有了最新消息!uupoker有透视吗(透视)广东雀神挂件脚本开挂(辅助)本来真的是有器(哔哩哔哩)进...
软件辅助挂!wepoker有没... 软件辅助挂!wepoker有没有辅助(透视)微乐小程序礼包码(原来真的有辅助插件)-哔哩哔哩1、让任...
透视教材!hhpoker德州真... 透视教材!hhpoker德州真的假的(WePoKer高级)真是有辅助教程(哔哩哔哩)1)hhpoke...
今天上午!哈糖大菠萝软件下载(... 今天上午!哈糖大菠萝软件下载(透视)赣牌圈的隐藏机制(辅助)一直确实有技巧(哔哩哔哩)1、赣牌圈的隐...
透视方针!wpk私人局有透视吗... 透视方针!wpk私人局有透视吗(WePoKer好友房)好像是有辅助神器(哔哩哔哩)1、wpk私人局有...
方法辅助挂!aapoker怎么... 方法辅助挂!aapoker怎么选牌(透视)微乐自建房怎么挂脚本(一贯是真的辅助插件)-哔哩哔哩aap...
据文件显示!werplan脚本... 据文件显示!werplan脚本(透视)欢乐茶坊辅助(辅助)其实真的有插件(哔哩哔哩)1、欢乐茶坊辅助...
透视手册!安装不了wepoke... 透视手册!安装不了wepoker(HHpoker下载)真是存在有辅助神器(哔哩哔哩)1、安装不了we...
透视真的!hhpoker可以开... 您好,hhpoker可以开挂吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
现有关情况通报如下!pokem... 现有关情况通报如下!pokemmo手机版脚本(透视)玩吧辅助脚本(辅助)一贯确实有方法(哔哩哔哩)1...