批量删除数据
delete_expr = "write_date_ts < 1743350400"
ins = MilvusTblGraphMapper()
col = ins.get_collection()
col.load()
limit = 10000
offset = 0
iterator = col.query_iterator(
expr=delete_expr,
output_fields=["graph_id"]
)
total =0
while True:
result = iterator.next()
if not result:
iterator.close()
break
results = []
for hit in result:
results.append(hit)
ids_to_delete = [result["graph_id"] for result in results]
total +=len(ids_to_delete)
print(total)
if ids_to_delete:
# 构建删除表达式
delete_expr = f"graph_id in {ids_to_delete}"
# 批量删除数据
try:
result = col.delete(expr=delete_expr)
print(f"删除结果: {result}")
except Exception as e:
print(f"删除失败: {e}")
else:
print("未查询到符合条件的数据,无需删除。")
milvus 连接的问题
gprc的版本问题,导致一段时间milvus连接出错
https://github.com/grpc/grpc/issues/38282
企业微信截图_a0e5082b-b382-4163-8439-b01358b9413d.png