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) 

相关内容

热门资讯

透视讲义!hhpoker德州透... 透视讲义!hhpoker德州透视挂,HHpoker方法确实是有脚本,第1分钟教程(有人有挂)hhpo...
第二分钟法门!中至上饶神辅助,... 第二分钟法门!中至上饶神辅助,新金龙辅助工具(辅助)竟然是有平台(哔哩哔哩)该软件可以轻松地帮助玩家...
透视总结!hhpoker有没有... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家在这款游戏中打...
透视代打!wepoker怎么获... 透视代打!wepoker怎么获得好牌,微乐小程序自建房辅助器下载,详情透视(有挂技巧)-哔哩哔哩1、...
透视秘籍!wepoker破解游... 透视秘籍!wepoker破解游戏盒子,WePoKer好牌切实是有教程,4分钟教程(有挂解密)1、用户...
第一分钟学习!微信小程序雀神挂... 第一分钟学习!微信小程序雀神挂件,火神大厅科技(辅助)其实真的有app(哔哩哔哩)微信小程序雀神挂件...
透视透视!aapoker辅助工... 透视透视!aapoker辅助工具安全吗,aapoker透视脚本下载(透视)其实存在有教程(哔哩哔哩)...
透视教程!xpoker辅助怎么... 透视教程!xpoker辅助怎么用,微信微乐陕西挖坑小程序破解器,分享脚本(有挂透视)-哔哩哔哩1、打...
透视指南!aapoker辅助软... 透视指南!aapoker辅助软件合法吗,AApoker逻辑都是是有辅助,十分钟教程(有挂讲解)透视指...
脚本总结!aapoker怎么控... 脚本总结!aapoker怎么控制牌,aapoker安装包怎么使用(透视)好像是有神器(哔哩哔哩)1、...