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) 

相关内容

热门资讯

普及透视!德普软件,wepok... 普及透视!德普软件,wepoker国外版透视,法门教程(有挂方式)-哔哩哔哩;所有人都在同一条线上,...
详细说明!蜀山四川麻亲友房祈福... 详细说明!蜀山四川麻亲友房祈福,wepoker线上大神,教程书教程(有挂技术)-哔哩哔哩一、蜀山四川...
推荐透视!pokemmo辅助器... 推荐透视!pokemmo辅助器脚本下载,wepoker怎么设置房间,步骤教程(有挂教学)-哔哩哔哩1...
热点推荐!!衢州都莱罗松辅助器... 热点推荐!!衢州都莱罗松辅助器,红龙poker作必弊指令,窍门教程(有挂存在)-哔哩哔哩;1、衢州都...
专业透视!约局吧辅助器,hhp... 专业透视!约局吧辅助器,hhpoker真的假的,技法教程(有挂神器)-哔哩哔哩1、专业透视!约局吧辅...
大神推荐!大唐辅助神器,aap... 大神推荐!大唐辅助神器,aapoker透视方法,办法教程(竟然有挂)-哔哩哔哩;1、下载好大唐辅助神...
专业透视!aa poker辅助... 专业透视!aa poker辅助包,pokemmo免费脚本,举措教程(详细教程)-哔哩哔哩运pokem...
记者揭秘!!四川熊猫辅助器,w... 记者揭秘!!四川熊猫辅助器,werplan免费挂下载,阶段教程(有挂存在)-哔哩哔哩1、实时werp...
有挂透视!wepoker分析,... 有挂透视!wepoker分析,hhpoker有没有作必弊挂,积累教程(证实有挂)-哔哩哔哩1.hhp...
必知教程!!wepoker辅助... 必知教程!!wepoker辅助软件,cloudpoker外开挂,经验教程(有挂技巧)-哔哩哔哩1、c...