mirror of https://github.com/milvus-io/milvus.git
Updated Searching with ANNOY index (markdown)
parent
15c80cb657
commit
3c33a8cb36
|
@ -37,7 +37,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,
|
||||||
|
@ -50,7 +55,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={
|
||||||
"search_k": -1 # int. {-1} U [top_k, n*n_trees], n represents vectors count.
|
"search_k": -1 # int. {-1} U [top_k, n*n_trees], n represents vectors count.
|
||||||
}, limit=top_k) # show results
|
}, limit=top_k) # show results
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue