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) 

相关内容

热门资讯

总算了解!奇迹陕西游戏辅助挂,... 总算了解!奇迹陕西游戏辅助挂,wepoker私人局开挂视频,详细开挂辅助app(证实有挂)1、打开软...
盘点一款!微乐三带辅助,hhp... 盘点一款!微乐三带辅助,hhpoker真的假的,详细开挂辅助技巧(有挂头条)微乐三带辅助软件透明挂微...
揭秘攻略!朱雀开心罗松可以开挂... 揭秘攻略!朱雀开心罗松可以开挂,sohoo poker辅助器,详细开挂辅助神器(有挂工具)亲,关键说...
教程攻略!多乐辅助app,德普... 教程攻略!多乐辅助app,德普之星私人局辅助器,详细开挂辅助攻略(有挂方法)1)德普之星私人局辅助辅...
热点推荐!同城游微信游戏辅助,... 热点推荐!同城游微信游戏辅助,wpk有那种辅助,详细开挂辅助工具(今日头条)1、许多玩家不知道同城游...
一分钟揭秘!新天道辅助器可以设... 一分钟揭秘!新天道辅助器可以设置,wepoker私人局俱乐部辅助,详细开挂辅助神器(新版有挂)1、新...
避坑细节!新道游app辅助器,... 避坑细节!新道游app辅助器,agpoker辅助,详细开挂辅助app(有挂教学)1、让任何用户在无需...
一分钟快速了解!花花生活圈可以... 一分钟快速了解!花花生活圈可以挂辅助,wpk模拟器,详细开挂辅助攻略(存在有挂)在进入花花生活圈可以...
避坑细节!插件脚本模板,wep... 避坑细节!插件脚本模板,wepoker能不能透视,详细开挂辅助工具(今日头条)1、这是跨平台的插件脚...
避坑细节!好友赣南辅助,hhp... 避坑细节!好友赣南辅助,hhpoker德州透视挂,详细开挂辅助插件(有挂方针)1、好友赣南辅助透视辅...