首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >milvus查询只返回一个结果。

milvus查询只返回一个结果。
EN

Stack Overflow用户
提问于 2022-09-19 15:37:00
回答 1查看 68关注 0票数 0

Milvus 2.1.2

我创建了一个由一个向量(vector)和一个字符串(im_id)组成的实体集合。

换句话说,我将一个图像id关联到每个向量。我能对向量进行研究。我正在尝试对图像id进行查询。

以下是代码:

代码语言:javascript
复制
#!venv/bin/python3

from pymilvus import (
    connections,
    utility,
    FieldSchema,
    CollectionSchema,
    DataType,
    Collection,
)

port = 30100
connections.connect("default", host="localhost", port=port)
utility.drop_collection("hello_milvus")
fields = [
    FieldSchema(name="im_id", dtype=DataType.VARCHAR,
                is_primary=True, auto_id=False,
                max_length=200),
    FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=2)
]
schema = CollectionSchema(fields)
hello_milvus = Collection("hello_milvus", schema)
hello_milvus.load()

vect1 = [10, 20]
vect2 = [3, 4]
vect3 = [5, 6]
im_id1 = "foo"
im_id2 = "bar"
im_id3 = "foo"

hello_milvus.insert([[im_id1], [vect1]]) # this is a foo
hello_milvus.insert([[im_id2], [vect2]]) # this is a bar
hello_milvus.insert([[im_id3], [vect3]]) # this is a foo

print(hello_milvus.num_entities)  # 3 entities, ok

results = hello_milvus.query(expr='im_id == "foo"',
                             output_fields=["vector"])

print("results", results)

这张照片:[{'im_id': 'foo', 'vector': [10.0, 20.0]}]

我试过一些变体,但我总是只得到一个结果。

有什么想法吗?我做错什么了?

EN

回答 1

Stack Overflow用户

发布于 2022-09-20 08:09:45

结果= hello_milvus.query(expr='im_id类“foo%”,output_fields=“载体”)

也许你可以试着用这种方法得到所有合格的结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73775948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档