mirror of https://github.com/milvus-io/milvus.git
Updated Searching with HSNW index (markdown)
parent
300412c3b3
commit
15c80cb657
|
@ -41,7 +41,12 @@ print(f"\nCreate collection...")
|
||||||
collection = Collection(name= collection_name, schema=default_schema)
|
collection = Collection(name= collection_name, schema=default_schema)
|
||||||
|
|
||||||
# insert data
|
# insert data
|
||||||
mr = collection.insert([xb])print(collection.num_entities)
|
import random
|
||||||
|
vectors = [[random.random() for _ in range(8)] for _ in range(10)]
|
||||||
|
entities = [vectors]
|
||||||
|
mr = collection.insert(entities)
|
||||||
|
print(collection.num_entities)
|
||||||
|
|
||||||
|
|
||||||
# create index
|
# create index
|
||||||
collection.create_index(field_name=field_name,
|
collection.create_index(field_name=field_name,
|
||||||
|
@ -55,7 +60,7 @@ collection.load()
|
||||||
|
|
||||||
# search
|
# search
|
||||||
top_k = 10
|
top_k = 10
|
||||||
results = collection.search(data=xq, anns_field="vector", param={
|
results = collection.search(vectors[:5], anns_field="vector", param={
|
||||||
"ef": 64
|
"ef": 64
|
||||||
}, limit=top_k)# show results
|
}, limit=top_k)# show results
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue