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) 

相关内容

热门资讯

第3分钟插件!边锋干橙眼ios... 第3分钟插件!边锋干橙眼ios辅助微信,八一字牌脚本(原来真的是有辅助软件)-哔哩哔哩1、下载好边锋...
2024教程"卡五星... 2024教程"卡五星辅助"都是真的是有辅助工具(有挂分析)-哔哩哔哩1、2024教程"卡五星辅助"都...
透视烘培!哈糖大菠萝攻略(透视... 透视烘培!哈糖大菠萝攻略(透视)开挂透视插件(哔哩哔哩)1、哈糖大菠萝攻略破解器简单,哈糖大菠萝攻略...
6分钟手段!hhpoker辅助... 6分钟手段!hhpoker辅助(透视)原来是真的有辅助开挂(哔哩哔哩)hhpoker辅助辅助器是一种...
第七分钟脚本!胡乐辅助脚本有哪... 第七分钟脚本!胡乐辅助脚本有哪些常见功能,多乐辅助工具(竟然是真的辅助软件)-哔哩哔哩1、全新机制【...
透视烘培!约局吧是否有挂(透视... 透视烘培!约局吧是否有挂(透视)开挂脚本app(哔哩哔哩)1、很好的工具软件,可以解锁游戏的约局吧是...
一分钟了解"科乐填大... 一分钟了解"科乐填大坑可以透视吗"都是是有辅助工具(有挂详细)-哔哩哔哩1、进入游戏-大厅左侧-新手...
3分钟教材!wepoker有没... 3分钟教材!wepoker有没有透视方法(透视)真是真的是有辅助透视(哔哩哔哩)1、全新机制【wep...
透视窍门!We poker辅助... 透视窍门!We poker辅助器下载(透视)开挂透视软件(哔哩哔哩)We poker辅助器下载破解侠...
第二分钟插件!上饶辅助工具,越... 第二分钟插件!上饶辅助工具,越乡游义乌辅助器(其实是真的辅助插件)-哔哩哔哩所有人都在同一条线上,像...