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) 

相关内容

热门资讯

专业讨论!wepoke防外挂,... 专业讨论!wepoke防外挂,微扑克辅助钻石,必胜教程(有挂助手)-哔哩哔哩;最新版2026是一款经...
2024版教学!(Wepoke... 2024版教学!(Wepoke德州版)外挂软件透明挂辅助app!(wpk微扑克辅助存在)力荐教程(2...
九分钟领会!aapoker透视... 九分钟领会!aapoker透视脚本下载,wepoker辅助器怎么用(透视)可靠技巧(有挂详细)1、起...
4分钟晓得!wepoke透明挂... 4分钟晓得!wepoke透明挂在哪买(透明挂黑科技)外挂透明挂辅助挂(2023已更新)(哔哩哔哩);...
规律辅助挂!aapoker透视... 规律辅助挂!aapoker透视辅助,德州ai辅助工具,技巧教程(存在有挂)-哔哩哔哩;德州ai辅助工...
大家学习交流!(微扑克模拟器)... 【福星临门,好运相随】;大家学习交流!(微扑克模拟器)外挂辅助器安装!(wpk线上德州俱乐部)科技教...
5分钟黑科技!xpoker辅助... 5分钟黑科技!xpoker辅助神器,wepoker私局代打(透视)黑科技教程(有挂实锤)1、下载好w...
六分钟知晓!微扑克有辅助吗(透... 六分钟知晓!微扑克有辅助吗(透明挂黑科技)外挂透明挂辅助神器(2023已更新)(哔哩哔哩);大家肯定...
黑科技软件!德州之星ai软件,... 黑科技软件!德州之星ai软件,wepoker系统规律,教你攻略(有挂解惑)-哔哩哔哩;人气非常高,a...
规律辅助挂!(微扑克代打)外挂... 规律辅助挂!(微扑克代打)外挂辅助透视!(wepoke透明黑科技)第三方教程(2026已更新)(哔哩...