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) 

相关内容

热门资讯

专业讨论!德扑之星真破解套路(... 专业讨论!德扑之星真破解套路(辅助挂)软件透明挂(有挂了解)-哔哩哔哩;人气非常高,ai更新快且高清...
每日必看!智星德州菠萝外挂检测... 每日必看!智星德州菠萝外挂检测(辅助挂)软件透明挂(有挂教学)-哔哩哔哩1、玩家可以在智星德州菠萝外...
透视透明挂!轰趴十三水有后台(... 轰趴十三水有后台赢率提升策略‌;透视透明挂!轰趴十三水有后台(辅助挂)软件透明挂(有挂详情)-哔哩哔...
发现玩家!德扑ai助手软件(辅... 发现玩家!德扑ai助手软件(辅助挂)透视辅助(有挂教学)-哔哩哔哩;玩家在德扑ai助手软件中需先进行...
一分钟了解!x-poker辅助... 一分钟了解!x-poker辅助软件(辅助挂)辅助透视(有挂攻略)-哔哩哔哩1、每一步都需要思考,不同...
一分钟揭秘!德州最新辅助器(辅... 一分钟揭秘!德州最新辅助器(辅助挂)透视辅助(有挂攻略)-哔哩哔哩;德州最新辅助器最新版本免费下载安...
玩家攻略推荐!德州辅助(辅助挂... 玩家攻略推荐!德州辅助(辅助挂)辅助透视(有挂了解)-哔哩哔哩是由北京得德州辅助黑科技有限公司精心研...
揭秘真相!pokernow德州... 《揭秘真相!pokernow德州(辅助挂)辅助透视(有挂介绍)-哔哩哔哩》 pokernow德州软件...
五分钟了解!德州之星辅助器(辅... 五分钟了解!德州之星辅助器(辅助挂)辅助透视(有挂透明)-哔哩哔哩1、很好的工具软件,可以解锁游戏的...
推荐一款!pokermaste... 1、推荐一款!pokermaster有外挂(辅助挂)透视辅助(有挂教学)-哔哩哔哩;详细教程。2、p...