关于milvus go sdk运行时报9223372036854775807 (untvped int constant)overflows int问题

背景

在使用milvus go sdk去查询milvus服务中并列出所有集合的时候遇到一个int溢出问题,依据官方文档,具体代码如下

package local

import (
	"context"
	"fmt"
	"github.com/milvus-io/milvus-sdk-go/v2/client"
	"log"
)

func Conn_Server() {
	Milvustestclient, err := client.NewGrpcClient(context.Background(), "172.19.5.119:19530")
	if err != nil {
		log.Fatalln("Faild to connect milvus server", err.Error())
	}
	defer Milvustestclient.Close()

	if collections, err := Milvustestclient.ListCollections(context.Background()); err != nil {
		log.Fatalf("Failed to list collections: %v", err)
	} else {
		fmt.Println("Collections in Milvus:")
		for _, collection := range collections {
			fmt.Println(collection)
		}
	}
}

在运行时抛出异常如下
在这里插入图片描述

解决方法

点击报错链接到相关代码行可以看到
在这里插入图片描述
看到是level给的是一个int类型,我们将这个类型改掉,改成uint64的,包括下面的reorder_k也更改为uint64类型即可

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Milvus是一个开源的向量相似度搜索引擎,而Knowhere是Milvus的核心组件之一,提供了各种向量索引和查询算法的实现。下面是关于Milvus和Knowhere的一些代码解释: 1. 连接到Milvus服务器: ```python from milvus import Milvus, IndexType, MetricType # 连接到Milvus服务器 milvus = Milvus(host='127.0.0.1', port='19530') ``` 2. 创建集合(collection): ```python collection_name = 'my_collection' dimension = 128 # 向量维度 # 创建集合 milvus.create_collection({'collection_name': collection_name, 'dimension': dimension}) ``` 3. 插入向量数据: ```python import numpy as np vectors = np.random.random((1000, 128)).astype(np.float32) # 随机生成向量数据 # 插入向量数据 milvus.insert(collection_name=collection_name, records=vectors) ``` 4. 创建索引: ```python index_param = {'index_type': IndexType.IVFLAT, 'metric_type': MetricType.L2} # 创建索引 milvus.create_index(collection_name=collection_name, index_param=index_param) ``` 5. 查询相似向量: ```python query_vector = np.random.random((1, 128)).astype(np.float32) # 随机生成查询向量 # 查询相似向量 results = milvus.search(collection_name=collection_name, query_records=query_vector, top_k=5) ``` 以上代码只是Milvus和Knowhere的一小部分示例,它们提供了更多的功能和选项,如删除集合、加载索引、设置查询参数等。你可以根据自己的需求进一步了解和使用Milvus和Knowhere。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值