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) 

相关内容

热门资讯

微乐小程序黑科技!微乐斗地主有... 微乐小程序黑科技!微乐斗地主有挂吗(开挂)插件-竟然揭幕真的是有挂1、游戏颠覆性的策略玩法,独创攻略...
据统计!微乐小程序黑科技,陕西... 据统计!微乐小程序黑科技,陕西微乐小程序攻略(作弊器)法门教程(总是存在有挂)1、有没有辅助教程、有...
透视科普!微乐小程序免费黑科技... 透视科普!微乐小程序免费黑科技(外挂),微乐小程序透视工具,教程秘籍(有挂解密)-哔哩哔哩1、这是跨...
微乐小程序黑科技!微乐小程序自... 微乐小程序黑科技!微乐小程序自建房辅助下载(开挂)攻略-本来分享是真的挂1. 选牌创建新账号,点击进...
昨日!微乐小程序黑科技,收i就... 昨日!微乐小程序黑科技,收i就微乐小程序游戏破解器(作弊器)窍门教程(其实是有挂)1、玩家可以在线上...
透视揭幕!微乐小程序黑科技(外... 透视揭幕!微乐小程序黑科技(外挂),微信小程序微乐辅助器免费版v2.0,教程妙计(证实有挂)-哔哩哔...
微乐小程序透视挂!微信小程序微... 微乐小程序透视挂!微信小程序微乐辅助器ios(开挂)挂-本来解迷有挂是不是有人用挂微扑克wpk插件教...
此事引发网友热议!微乐小程序黑... 此事引发网友热议!微乐小程序黑科技,微乐小程序自建房透视免费(作弊器)方式教程(一贯真的有挂)进入游...
透视总结!微乐小程序黑科技(外... 透视总结!微乐小程序黑科技(外挂),微乐透视辅助功能插件下载,教程指引(有挂教程)-哔哩哔哩1、完成...
微信小程序黑科技免费!微乐小程... 微信小程序黑科技免费!微乐小程序辅助工具(开挂)方法-切实了解是真的挂1、玩家可以在透视最简单三个步...