| 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')}") | |