File size: 999 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
25
26
27
28
29
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 the collection to find entries where the 'name' field is empty or None
query = 'name == "YAB DATO SERI ANWAR IBRAHIM"'  # Looking for entities where 'name' is empty

# Perform the query to find entities with empty 'name' fields
results = collection.query(query, output_fields=["id", "name"])

# Check and delete entities with empty 'name'
if results:
    ids_to_delete = [str(result["id"]) for result in results]
    id_expr = f"id in [{', '.join(ids_to_delete)}]"
    collection.delete(expr=id_expr)
    print(f"✅ Deleted entities: {ids_to_delete}")
else:
    print("❌ No entities found for deletion.")