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) 

相关内容

热门资讯

总算了解!!约局吧作必弊脚本,... 总算了解!!约局吧作必弊脚本,微乐游戏竞技团辅助(透视)确实真的有工具(哔哩哔哩)1、点击下载安装,...
不少玩家反映!智星菠萝辅助,微... 不少玩家反映!智星菠萝辅助,微乐老友广东辅助器(透视)好像是有方法(哔哩哔哩)1)微乐老友广东辅助器...
重大消息!约局吧如何查看是否有... 重大消息!约局吧如何查看是否有挂,微信微乐辅助器使用教程(透视)竟然有有插件(哔哩哔哩)1、点击下载...
推荐攻略!拱趴大菠萝怎么开挂,... 推荐攻略!拱趴大菠萝怎么开挂,微信微乐挂有没有(透视)本来是真的有app(哔哩哔哩)微信微乐挂有没有...
玩家必看科普!xpoker透视... 玩家必看科普!xpoker透视辅助,微乐自建房辅助软件如何下载(透视)切实是真的有技巧(哔哩哔哩)1...
玩家亲测!哈糖大菠萝怎么开挂,... 玩家亲测!哈糖大菠萝怎么开挂,微乐自建房插件详细教程(透视)好像真的有器(哔哩哔哩)1、操作简单,无...
盘点几款!哈糖大菠萝有挂吗5个... 盘点几款!哈糖大菠萝有挂吗5个常用方法,微乐陕西小程序破解器(透视)都是存在有软件(哔哩哔哩)1、金...
有玩家发现!竞技联盟破解版最新... 有玩家发现!竞技联盟破解版最新版,微乐家乡官方app下载(透视)总是存在有技巧(哔哩哔哩)1、实时微...
玩家必看教程!!we poke... 玩家必看教程!!we poker免费辅助器,微乐自建房黑科技辅助工具下载(透视)总是是有软件(哔哩哔...
专业讨论!!哈糖大菠萝有挂吗5... 专业讨论!!哈糖大菠萝有挂吗5个常用方法,微乐小程序免费黑科技下载方法(透视)一直真的是有脚本(哔哩...