创建索引

为提高向量搜索的效率,你可以为 collection 中的某一列 Field 创建索引。具体索引参数设置详见向量索引

  1. 准备相关参数:
>>> index_param = {
        "metric_type":"L2",
        "index_type":"IVF_FLAT",
        "params":{"nlist":1024}
    }
const index_param = {
  metric_type: "L2",
  index_type: "IVF_FLAT",
  params: JSON.stringify({ nlist: 1024 }),
};
  1. 创建索引:
>>> collection.create_index(field_name=field_name, index_params=index_param)
Status(code=0, message='')
await milvusClient.indexManager.createIndex({
  collection_name: COLLECTION_NAME,
  field_name: FIELD_NAME,
  extra_params: index_param,
});
  1. 查看创建的索引相关信息:
>>> collection.index().params
{'metric_type': 'L2', 'index_type': 'IVF_FLAT', 'params': {'nlist': 1024}}
await milvusClient.indexManager.describeIndex({
  collection_name: COLLECTION_NAME,
});
该页面是否对你有帮助?
评价成功!