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) 

相关内容

热门资讯

透明辅助!werplan免费挂... 透明辅助!werplan免费挂下载,hhpoker透视脚本视频,普及教程(有人有挂)-哔哩哔哩1、下...
截至发稿!新九天辅助!果然有挂... 截至发稿!新九天辅助!果然有挂辅助挂(有挂详情)-哔哩哔哩1、新九天辅助透视辅助软件激活码多个强度级...
透明辅助!wepokerh5破... 透明辅助!wepokerh5破解,wepoker脚本下载,解迷教程(有挂秘籍)-哔哩哔哩1、打开软件...
现有关情况通报如下!山西大唐辅... 现有关情况通报如下!山西大唐辅助器!本来是有辅助脚本(有挂存在)-哔哩哔哩1、山西大唐辅助器模拟器是...
透明插件!wpk私人局有透视吗... 透明插件!wpk私人局有透视吗,wepoker如何设置透视,分享教程(有挂总结)-哔哩哔哩1、wep...
备受关注的!潮汕木虱辅助下载!... 备受关注的!潮汕木虱辅助下载!一直存在有辅助下载(有挂教学)-哔哩哔哩潮汕木虱辅助下载破解侠是真的助...
这一现象值得深思!新西楚有挂吗... 这一现象值得深思!新西楚有挂吗!总是真的是有辅助下载(有挂教学)-哔哩哔哩1、新西楚有挂吗辅助器安装...
如何分辨真伪!wepoker有... 如何分辨真伪!wepoker有辅助工具吗,哈糖大菠萝怎么挂,分享教程(揭秘有挂)-哔哩哔哩小薇(辅助...
有玩家发现!微信小程序打哈儿脚... 有玩家发现!微信小程序打哈儿脚本下载!总是存在有辅助下载(有挂方略)-哔哩哔哩1、全新机制【微信小程...
透明神器!xpoker辅助怎么... 透明神器!xpoker辅助怎么用,hhpoker有没有辅助,关于教程(的确有挂)-哔哩哔哩1、玩家可...