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透明挂... 我来教大家!wepoke透明挂辅助软件是真的吗(黑科技)外挂智能ai辅助app(揭秘有挂)-哔哩哔哩...
黑科技美元局!xpoker透视... 黑科技美元局!xpoker透视辅助(透视)必赢方法(2021已更新)(哔哩哔哩);一、xpoker透...
科技通报!微扑克软件发牌管理(... 1、科技通报!微扑克软件发牌管理(黑科技)外挂黑科技ai辅助app(有人有挂)-哔哩哔哩;该软件可以...
黑科技有挂!微扑克代打是真的吗... 黑科技有挂!微扑克代打是真的吗(透视)曝光教程(2026已更新)(哔哩哔哩)1、进入游戏-大厅左侧-...
热点讨论!德州数据辅助器(黑科... 一、德州数据辅助器简介了解软件请加微:136704302德州数据辅助器是一款在线扑克游戏平台,玩家可...
黑科技模拟器!wepoke有插... 黑科技模拟器!wepoke有插件吗(透视)wepoke教程(2024已更新)(哔哩哔哩);1、很好的...
实测必看!!wepoke软件透... 实测必看!!wepoke软件透明挂怎么弄(黑科技)外挂透明黑科技辅助助手(有挂规律)-哔哩哔哩是一款...
黑科技脚本!wepokeplu... 黑科技脚本!wepokeplus透明挂怎么识别(透视)插件教程(2022已更新)(哔哩哔哩)在进入w...
终于清楚!fishpoker正... 终于清楚!fishpoker正规吗(黑科技)外挂ai代打辅助神器(竟然有挂)-哔哩哔哩1、超多福利:...
黑科技最新!微扑克钻石能提高胜... 黑科技最新!微扑克钻石能提高胜率吗(透视)技巧教程(2026已更新)(哔哩哔哩)1、任何微扑克钻石能...