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) 

相关内容

热门资讯

透视神器!黑侠破解wepoke... 透视神器!黑侠破解wepoker(透视)永久脚本辅助软件(详细辅助软件教程)1)黑侠破解wepoke...
科普分享!余干510k副510... 科普分享!余干510k副510k,胡乐安庆辅助工具,2025新版(有挂了解);无聊就玩这款胡乐安庆辅...
透视安卓版!hhpoker德州... 透视安卓版!hhpoker德州真的假的(透视)永久脚本辅助方法(详细辅助wepoke教程);1、金币...
分享一款!创思维激k透视在哪里... 分享一款!创思维激k透视在哪里买,海贝之城辅助,必备教程(有挂介绍);致您一封信;亲爱创思维激k透视...
透视软件!线上德州的辅助器是什... 透视软件!线上德州的辅助器是什么(透视)永久脚本辅助app(详细辅助2025新版教程)1、线上德州的...
重要通知!新海贝之城开挂,开心... 重要通知!新海贝之城开挂,开心十三水辅助工具,教你攻略(有挂教学)1)开心十三水辅助工具辅助挂:进一...
玩家必看科普!衢州都莱罗松怎么... 玩家必看科普!衢州都莱罗松怎么老是输,财神十三章辅助官网入口,辅助教程(有挂黑科技)1)衢州都莱罗松...
透视智能ai!pokemmo脚... 透视智能ai!pokemmo脚本辅助器下载(透视)永久脚本辅助挂(详细辅助可靠技巧)1、pokemm...
今日公布!万能透视辅助器免费版... 今日公布!万能透视辅助器免费版,佛手在线大菠萝辅助,新2025教程(有挂教学)您好,万能透视辅助器免...
透视实锤!aapoker脚本怎... 透视实锤!aapoker脚本怎么用(透视)永久脚本辅助器(详细辅助揭秘攻略)1)aapoker脚本怎...