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怎么下载游戏,hhpoker俱乐部是干嘛的,原来真的有挂(有挂细节)...
刚刚!智星菠萝透视,拱趴大菠萝... 刚刚!智星菠萝透视,拱趴大菠萝挂,果然是有挂(有挂规律)1)拱趴大菠萝挂辅助插件:进一步探索拱趴大菠...
这一问题亟待解决!wepoke... 这一问题亟待解决!wepoker怎么挂底牌,wpk辅助购买,真是存在有挂(有挂教学)1、wepoke...
备受关注的!哈糖大菠萝辅助器,... 备受关注的!哈糖大菠萝辅助器,德扑圈透视挂,确实是有挂(有挂教程)1、让任何用户在无需哈糖大菠萝辅助...
围绕透视问题!hhpoker可... 围绕透视问题!hhpoker可以控制吗,约局吧开挂,竟然存在有挂(有挂分享)所有人都在同一条线上,像...
插件辅助挂!pokernow辅... 插件辅助挂!pokernow辅助控制,wepoker好友助力码,果然是真的有挂(证实有挂)1)wep...
黑科技辅助挂!uupoker有... 黑科技辅助挂!uupoker有透视吗,wepokerplus外挂,真是是真的有挂(有挂细节)1、点击...
网友热议!德州之星扫描器,we... 网友热议!德州之星扫描器,wepoker俱乐部辅助,都是是真的有挂(揭秘有挂)1.wepoker俱乐...
黑科技辅助挂!红龙poker有... 黑科技辅助挂!红龙poker有辅助吗,wepoker破解工具,好像确实有挂(有挂辅助)1、在红龙po...
2026版攻略!aapoker... 2026版攻略!aapoker发牌逻辑,德普之星私人局辅助器,一贯真的是有挂(真的有挂)1、完成德普...