pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

[Bug]: Collection query returns empty response unless num_entities is called on the collection

Open mmhealey1 opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

When I load a collection into memory in milvus and try to query it, it returns empty responses even though there are entities in the collection. If I subsequently call num_entities on the collection, it starts returning responses as expected.

Expected Behavior

I should not need to call num_entities on a collection after loading it into memory to return queries.

Steps/Code To Reproduce behavior

import pymilvus as pm
       
pm.connections.connect(MILVUS_ALIAS, host=MILVUS_HOST, port=MILVUS_PORT)
collection = pm.Collection(collection_name)
collection.load()
embedding =collection.query(
    expr=f'pk in {[primary_key]}',
    output_fields=["embedding"],
    consistency_level="Bounded"
)

embedding here is None

If I run

collection.num_entities
embedding =collection.query(
    expr=f'pk in {[primary_key]}',
    output_fields=["embedding"],
    consistency_level="Bounded"
)

embedding is not None

Environment details

- K8s
- pymilvus version: 2.1.1
- Milvus helm chart
    version: 3.0.24
    repository: https://milvus-io.github.io/milvus-helm/

Anything else?

No response

mmhealey1 avatar Sep 22 '22 12:09 mmhealey1