from pymilvus import connections, FieldSchema, CollectionSchema, DataType, Collection ,utility
#测试环境建好了 114.55.115.191:19530
# 连接到 Milvus
#connections.connect("default", host="114.55.115.191", port="19530")#本地测试
#connections.connect("default", host="124.71.157.162", port="19530")#生产环境
# connections.connect("default", host="124.70.129.232", port="19530")#测试环境
#connections.connect("default", host="1.94.113.19", port="19530")#测试环境13
connections.connect("default", host="1.94.60.103", port="19530")#测试环境103


#connections.connect("default", host="192.168.0.129", port="19530")
collections = utility.list_collections()
#生产：1.94.179.121
#测试：114.55.115.191
# 输出集合列表
print("Collections in Milvus:")
for collection in collections:
    print(collection)

collection = Collection(name='pdf_measure_v4')

# 获取集合的详细信息
#print(f"Collection name: {collection.name}")
print(f"Collection schema: {collection.schema}")
print(f"Number of entities in collection: {collection.num_entities}")
search_vectors = collection.load()
entities = collection.query(expr="file_id == '39369'", output_fields=["table_num","table_index","measure_name","measure_value","measure_unit","file_id"],limit = 10)
count = 0
# # # 输出集合中的数据
print("Data in collection:")
for entity in entities:
    print(entity)
    count += 1
print(f'这个条件下数据量为{count}')
connections.disconnect('default')