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) 

相关内容

热门资讯

科技新动态!pokemmo辅助... 科技新动态!pokemmo辅助器-详细开挂透视辅助软件(有开挂透视);1、这是跨平台的pokemmo...
玩家攻略!wepoker辅助工... 【福星临门,好运相随】;玩家攻略!wepoker辅助工具-详细开挂透视辅助黑科技(有开挂工具);暗藏...
2024教程!hhpoker是... 2024教程!hhpoker是真的假的,hhpoker有辅助吗,插件教程(了解有挂);相信小伙伴都知...
总算明白!wepokerplu... 您好:wepokerplus开挂这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很...
推荐攻略!红龙poker有辅助... 您好:红龙poker有辅助吗这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用...
透视规律!八闽十三水破解版辅助... 透视规律!八闽十三水破解版辅助,东阳四副牌辅助,详细教程(有挂秘笈)一、八闽十三水破解版辅助AI软件...
一分钟了解!wpk透视辅助-详... 一分钟了解!wpk透视辅助-详细开挂透视辅助下载(有开挂猫腻);相信小伙伴都知道这个wpk透视辅助上...
科技分享!好友赣南能装挂吗,赣... 科技分享!好友赣南能装挂吗,赣牌圈破解器,揭秘攻略(有挂神器)是一款可以让一直输的玩家,快速成为一个...
三分钟了解!wepoker辅助... 三分钟了解!wepoker辅助器官方,大菠萝免费辅助器,技巧教程(有人有挂);大菠萝免费辅助器软件透...
重大发现!点我休闲辅助器,琼戏... 重大发现!点我休闲辅助器,琼戏互娱破解版,力荐教程(讲解有挂)1、该软件可以轻松地帮助玩家将琼戏互娱...