Spaces:
Runtime error
Runtime error
Saiteja Solleti
commited on
Commit
·
cf42161
1
Parent(s):
5dce073
issue
Browse files- createmilvusschema.py +15 -13
createmilvusschema.py
CHANGED
|
@@ -32,17 +32,19 @@ def CreateMilvusDbSchema():
|
|
| 32 |
# Create the collection in Milvus
|
| 33 |
collection = Collection(name=COLLECTION_NAME, schema=schema)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
"
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
print("Index created successfully.")
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 32 |
# Create the collection in Milvus
|
| 33 |
collection = Collection(name=COLLECTION_NAME, schema=schema)
|
| 34 |
|
| 35 |
+
try:
|
| 36 |
+
# Create an optimized index for fast vector search
|
| 37 |
+
collection.create_index(
|
| 38 |
+
"chunk_embedding",
|
| 39 |
+
{
|
| 40 |
+
"index_type": "HNSW", # Hierarchical Navigable Small World (HNSW) index
|
| 41 |
+
"metric_type": "COSINE", # Cosine similarity for vector search
|
| 42 |
+
"params": {"M": 16, "efConstruction": 200} # HNSW parameters
|
| 43 |
+
}
|
| 44 |
+
)
|
| 45 |
print("Index created successfully.")
|
| 46 |
+
print(f"Collection '{COLLECTION_NAME}' created successfully.")
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print(f"Failed to create index: {e}")
|
| 49 |
+
finally:
|
| 50 |
+
return collection
|