Commit 1bd6fd5b authored by zhengyaoqiu's avatar zhengyaoqiu

创建表&索引

parent 256977d0
from typing import List
from pymilvus import FieldSchema, DataType
from app.services.milvus import MilvusClient
def main():
host = "10.0.40.12"
fields: List[FieldSchema] = [
FieldSchema(name="image", dtype=DataType.VARCHAR, max_length=256, is_primary=True, auto_id=False),
FieldSchema(name="key", dtype=DataType.VARCHAR, max_length=256),
FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=512) # CLIP ViT-B/32的特征维度为512
]
MilvusClient(host=host).connect().create_collection("mpc", fields, "mpc 图片向量存储")
index_params = {
"index_type": "HNSW",
"metric_type": "IP", # 内积相似度
"params": {"M": 40, "efConstruction": 600, "ef": 400}
}
MilvusClient(host=host).connect().create_index("mpc", "vector", index_params)
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment