linux安装milvus数据库lite版本

2024-09-02 05:04

本文主要是介绍linux安装milvus数据库lite版本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

https://milvus.io/docs/milvus_lite.md

参考上述教程,直接安装该包即可。标准版和分布式版要运行docker。

pip install -U pymilvus

下面是官方的demo,一起看看

from pymilvus import MilvusClient # 导入库,客户端
import numpy as np # # 创建客户端,并连接到一个名为 milvus_demo.db 的本地数据库。这个文件将用于存储 Milvus 数据库的索引和数据
client = MilvusClient("/root/RAG/milvus/milvus_demo.db")
client.create_collection(collection_name="demo_collection",dimension=4  # The vectors we will use in this demo has 384 dimensions
) # 创建集合,设置名称和向量维度数# 待加入的文本,三条。
docs = ["Artificial intelligence was founded as an academic discipline in 1956.","Alan Turing was the first person to conduct substantial research in AI.","Born in Maida Vale, London, Turing was raised in southern England.",
]
# 为这些文本构建虚拟向量
vectors = [[ np.random.uniform(-1, 1) for _ in range(4) ] for _ in range(len(docs)) ]
print(vectors)# 构建json字典,这是真正传入数据库的东西
data = [ {"id": i, "vector": vectors[i], "text": docs[i], "subject": "history"} for i in range(len(vectors)) ]
# insert方法插入数据
res = client.insert(collection_name="demo_collection",data=data
)
print(data)# 检索数据,传入Query向量,结合布尔检索
res = client.search(collection_name="demo_collection",data=[vectors[0]],filter="subject == 'history'",limit=2,output_fields=["text", "subject"],
)
print(res)# 查询数据,纯布尔检索
res = client.query(collection_name="demo_collection",filter="subject == 'history'",output_fields=["text", "subject"],
)
print(res)# 根据布尔条件删除记录
res = client.delete(collection_name="demo_collection",filter="subject == 'history'",
)
print(res)

输出:
vector:

[[-0.18993033343249377, -0.853204716673974, -0.6934232192055412, -0.7363553533144986], [0.6506801349937705, -0.5114297246706443, -0.6227428721418204, -0.4484672597247552], [0.3325751425210133, -0.5403168744637166, 0.6497994854622242, -0.7438264838676247]]

data:

[{'id': 0, 'vector': [-0.18993033343249377, -0.853204716673974, -0.6934232192055412, -0.7363553533144986], 'text': 'Artificial intelligence was founded as an academic discipline in 1956.', 'subject': 'history'}, {'id': 1, 'vector': [0.6506801349937705, -0.5114297246706443, -0.6227428721418204, -0.4484672597247552], 'text': 'Alan Turing was the first person to conduct substantial research in AI.', 'subject': 'history'}, {'id': 2, 'vector': [0.3325751425210133, -0.5403168744637166, 0.6497994854622242, -0.7438264838676247], 'text': 'Born in Maida Vale, London, Turing was raised in southern England.', 'subject': 'history'}]

search的res:

data: ["[{'id': 0, 'distance': 1.0, 'entity': {'text': 'Artificial intelligence was founded as an academic discipline in 1956.', 'subject': 'history'}}, {'id': 1, 'distance': 0.7123634815216064, 'entity': {'text': 'Alan Turing was the first person to conduct substantial research in AI.', 'subject': 'history'}}]"]

query的res:

data: ["{'id': 0, 'text': 'Artificial intelligence was founded as an academic discipline in 1956.', 'subject': 'history'}", "{'id': 1, 'text': 'Alan Turing was the first person to conduct substantial research in AI.', 'subject': 'history'}", "{'id': 2, 'text': 'Born in Maida Vale, London, Turing was raised in southern England.', 'subject': 'history'}"] 

delete的res:

[0, 1, 2]

在创建集合并插入数据时,Milvus 会默认使用 FLAT(扁平)索引。
可以在插入数据之后随时创建或修改索引。

这篇关于linux安装milvus数据库lite版本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1129070

相关文章

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

linux-基础知识3

打包和压缩 zip 安装zip软件包 yum -y install zip unzip 压缩打包命令: zip -q -r -d -u 压缩包文件名 目录和文件名列表 -q:不显示命令执行过程-r:递归处理,打包各级子目录和文件-u:把文件增加/替换到压缩包中-d:从压缩包中删除指定的文件 解压:unzip 压缩包名 打包文件 把压缩包从服务器下载到本地 把压缩包上传到服务器(zip

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我

Linux 网络编程 --- 应用层

一、自定义协议和序列化反序列化 代码: 序列化反序列化实现网络版本计算器 二、HTTP协议 1、谈两个简单的预备知识 https://www.baidu.com/ --- 域名 --- 域名解析 --- IP地址 http的端口号为80端口,https的端口号为443 url为统一资源定位符。CSDNhttps://mp.csdn.net/mp_blog/creation/editor

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal