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) 

相关内容

热门资讯

7分钟解谜!hhpoker德州... 7分钟解谜!hhpoker德州真的假的(透视)都是真的有挂,教你教程(有挂神器)-哔哩哔哩1、进入到...
透视黑科技!wepoker安装... 透视黑科技!wepoker安装教程(透视)都是存在有挂,力荐教程(有挂科技)-哔哩哔哩一、wepok...
透视辅助!wpk辅助器,aa ... 透视辅助!wpk辅助器,aa poker辅助,指南教程(有挂攻略)-哔哩哔哩1、不需要AI权限,帮助...
第6分钟普及!悦扑克脚本(透视... 第6分钟普及!悦扑克脚本(透视)本来真的是有挂,力荐教程(真是有挂)-哔哩哔哩1)悦扑克脚本辅助挂:...
透视美元局!wepoker辅助... 透视美元局!wepoker辅助工具(透视)原来存在有挂,必赢方法(有挂内置)-哔哩哔哩1、游戏颠覆性...
透视存在!wepoker到底有... 透视存在!wepoker到底有没有透视,wepoker辅助脚本,妙计教程(有挂教学)-哔哩哔哩1、游...
两分钟解密!德州真人透视脚本(... 两分钟解密!德州真人透视脚本(透视)本来真的有挂,教你教程(有人有挂)-哔哩哔哩一、德州真人透视脚本...
透视有挂!wepoker开脚本... 透视有挂!wepoker开脚本视频(透视)原来是真的挂,介绍教程(有挂中牌率)-哔哩哔哩1、让任何用...
透视辅助!wepoker游戏安... 透视辅助!wepoker游戏安装教程,wepoker破解是真的还是假的,方式教程(有挂技巧)-哔哩哔...
1分钟分享!pokemmo脚本... 1分钟分享!pokemmo脚本(透视)其实是有挂,总结教程(真是有挂)-哔哩哔哩1、首先打开poke...