File size: 800 Bytes
090987a bc62936 090987a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from pymilvus import Collection, connections
from dotenv import load_dotenv
import os
load_dotenv()
milvus_host = os.getenv("MILVUS_HOST", "milvus") # default localhost
milvus_port = os.getenv("MILVUS_PORT", "19530") # default 19530
connections.connect("default", host=milvus_host, port=int(milvus_port))
# Now, connect to the collection
collection = Collection("faces")
# Query expression that retrieves all documents with a non-null 'id' (or use any valid field)
query = "id IS NOT NULL" # Valid query expression to fetch all documents
# Retrieve all documents, adjust fields based on your collection schema
results = collection.query(query, output_fields=["id", "name"])
# Print all results
for result in results:
print(f"ID: {result['id']}, Name: {result.get('name', 'N/A')}")
|