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) 

相关内容

热门资讯

第5分钟了解!游戏破解器100... 第5分钟了解!游戏破解器100%破解(辅助)天辰开挂辅助辅助-竟然真的有插件1、游戏破解器100%破...
透视烘培!aapoker透视脚... 透视烘培!aapoker透视脚本(WPK方法)好像存在有辅助软件(哔哩哔哩)1、aapoker透视脚...
透视了解!微乐小程序黑科技免费... 透视了解!微乐小程序黑科技免费(透视)微信微乐辅助器使用教程(本来存在有辅助神器)-哔哩哔哩1、辅助...
一分钟了解!凑一桌游戏辅助神器... 一分钟了解!凑一桌游戏辅助神器(辅助)天天爱蚌埠麻将开挂辅助下载-真是真的是有平台1、许多玩家不知道...
透视技法!wejoker辅助脚... 透视技法!wejoker辅助脚本(HHpoker软件)竟然是有辅助工具(哔哩哔哩)wejoker辅助...
据了解!微乐小程序黑科技(透视... 据了解!微乐小程序黑科技(透视)微乐自建房安装挂免费(原来是有辅助修改器)-哔哩哔哩据了解!微乐小程...
4分钟了解!科技新星游牛牛辅助... 4分钟了解!科技新星游牛牛辅助(辅助)边锋老友宁安麻将开挂辅助工具-竟然真的有app1、科技新星游牛...
透视项目!wepoker辅助器... 透视项目!wepoker辅助器如何使用(WePoKer挂)都是有辅助app(哔哩哔哩)1、wepok...
近年来!微乐小程序黑科技免费(... 近年来!微乐小程序黑科技免费(透视)微信微乐游戏破解器(原来是有辅助修改器)-哔哩哔哩1、首先打开辅...
7分钟了解!江汉晃晃辅助器(辅... 7分钟了解!江汉晃晃辅助器(辅助)秋之枫华开挂辅助平台-都是真的是有安装1、江汉晃晃辅助器辅助器安装...