Spaces:
Sleeping
Sleeping
januarevan
commited on
Commit
•
6c5586b
1
Parent(s):
37db268
init
Browse files
main.py
CHANGED
@@ -62,18 +62,20 @@ def create_a_collection(milvus_client, collection_name):
|
|
62 |
schema=schema
|
63 |
)
|
64 |
|
|
|
|
|
65 |
# Create an index for the collection
|
66 |
# IVF_FLAT index is used here, with metric_type COSINE
|
67 |
index_params = {
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
72 |
}
|
73 |
-
}
|
74 |
|
75 |
# Create the index on the vector field
|
76 |
-
|
77 |
collection_name=collection_name,
|
78 |
field_name="vector",
|
79 |
index_params=index_params # Pass the dictionary, not a string
|
|
|
62 |
schema=schema
|
63 |
)
|
64 |
|
65 |
+
collection = Collection(name=collection_name, milvus_client=milvus_client)
|
66 |
+
|
67 |
# Create an index for the collection
|
68 |
# IVF_FLAT index is used here, with metric_type COSINE
|
69 |
index_params = {
|
70 |
+
"index_type": "IVF_FLAT",
|
71 |
+
"metric_type": "COSINE",
|
72 |
+
"params": {
|
73 |
+
"nlist": 128
|
74 |
+
}
|
75 |
}
|
|
|
76 |
|
77 |
# Create the index on the vector field
|
78 |
+
collection.create_index(
|
79 |
collection_name=collection_name,
|
80 |
field_name="vector",
|
81 |
index_params=index_params # Pass the dictionary, not a string
|