update hello_milvus.py (#23879)

Signed-off-by: jjyaoao <jjyaoao@126.com>
pull/23990/head
jjyaoao 2023-05-09 20:29:10 +08:00 committed by GitHub
parent 38e60804a4
commit 893e31d13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -68,13 +68,6 @@ def hello_milvus(host="127.0.0.1"):
t1 = time.time()
print(f"\nGet collection entities cost {t1 - t0:.4f} seconds")
# create index and load table
default_index = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
print(f"\nCreate index...")
t0 = time.time()
collection.create_index(field_name="float_vector", index_params=default_index)
t1 = time.time()
print(f"\nCreate index cost {t1 - t0:.4f} seconds")
print("\nGet replicas number")
try:
replicas_info = collection.get_replicas()
@ -83,6 +76,17 @@ def hello_milvus(host="127.0.0.1"):
except Exception as e:
print(str(e))
replica_number = 1
# create index and load table
default_index = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
print(f"\nCreate index...")
t0 = time.time()
collection.release()
collection.create_index(field_name="float_vector", index_params=default_index)
t1 = time.time()
print(f"\nCreate index cost {t1 - t0:.4f} seconds")
print(f"\nload collection...")
t0 = time.time()
collection.load(replica_number=replica_number)