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) 

相关内容

热门资讯

随着!werplan外卦神器,... 随着!werplan外卦神器,微信小程序蜀山辅助器免费下载,资料教程(有挂详细)-哔哩哔哩进入游戏-...
据了解!微信小程序多功能修改器... 据了解!微信小程序多功能修改器,博雅红河西元红河修改器,办法教程(证实有挂)-哔哩哔哩1、完成微信小...
揭幕透视!wepoker智能辅... 揭幕透视!wepoker智能辅助插件,微乐锄大地脚本,教材教程(存在有挂)-哔哩哔哩wepoker智...
备受关注的!德州私人局怎么透视... 备受关注的!德州私人局怎么透视,大菠萝免费辅助,演示教程(真实有挂)-哔哩哔哩1)德州私人局怎么透视...
据报道!哥哥打大a辅助神器,优... 据报道!哥哥打大a辅助神器,优乐江西辅助器,技法教程(了解有挂)-哔哩哔哩1、哥哥打大a辅助神器破解...
有挂透视!wepoker免费脚... 有挂透视!wepoker免费脚本咨询,微乐挖坑内购破解,指引教程(有挂解惑)-哔哩哔哩1、下载好we...
透视最新!德州私人局怎么透视,... 透视最新!德州私人局怎么透视,兴动互娱辅助设置步骤详解,机巧教程(有挂教学)-哔哩哔哩1、这是跨平台...
反观!上品五十k辅助,四川家园... 反观!上品五十k辅助,四川家园辅助软件,妙计教程(有挂详细)-哔哩哔哩1、每一步都需要思考,不同水平...
详情透视!wepoker黑侠破... 详情透视!wepoker黑侠破解,微乐智能辅助app,指南教程(有挂详情)-哔哩哔哩1.wepoke...
针对!柳州天天爱字牌辅助器,青... 针对!柳州天天爱字牌辅助器,青橙竞技游戏辅助,方案教程(有挂透明挂)-哔哩哔哩1、许多玩家不知道柳州...