python开发milvus2.0.2开发,快速上手,参考文档、手册、案例
参考文档开发案例:https://gitee.com/AI-Mart/pymilvus/blob/master/examples/hello_milvus.pyhttps://github.com/milvus-io/pymilvus/blob/master/examples/hello_milvus.py参考指南:https://milvus.io/docs/v2.0.x/manage_conn
·
参考文档
开发案例:
https://gitee.com/AI-Mart/pymilvus/blob/master/examples/hello_milvus.py
https://github.com/milvus-io/pymilvus/blob/master/examples/hello_milvus.py
参考指南:
https://milvus.io/docs/v2.0.x/manage_connection.md
python开发api文档:
https://milvus.io/api-reference/pymilvus/v2.0.2/About.md
代码记录
1、创建集合
hello_milvus = Collection("hello_milvus", schema, consistency_level="Strong")
注意1
Milvus supports setting consistency level while creating a collection (only on PyMilvus currently). In this example, the consistency level of the collection is set as "Strong", meaning Milvus will read the most updated data view at the exact time point when a search or query request comes. By default, a collection created without specifying the consistency level is set with bounded consistency level, under which Milvus reads a less updated data view (usually several seconds earlier) when a search or query request comes. Besides collection creation, you can also set the consistency level specifically for search or query (only on PyMilvus currently). For other consistency level supported by Milvus, see Guarantee Timestamp in Search Requests.
注意2
The collection to create must contain a primary key field and a vector field. INT64 is the only supported data type for the primary key field in current release of Milvus.
2、 创建索引
# 4. create index
print(fmt.format("Start Creating index IVF_FLAT"))
index = {
"index_type": "IVF_FLAT",
"metric_type": "L2",
"params": {"nlist": 128},
}
hello_milvus.create_index("embeddings", index)
注意1
# We are going to create an IVF_FLAT index for hello_milvus collection.
# create_index() can only be applied to `FloatVector` and `BinaryVector` fields.
Vector indexes are an organizational unit of metadata used to accelerate vector similarity search. Without index built on vectors, Milvus will perform a brute-force search by default
注意2
Current release of Milvus only supports index on vector field. Future releases will support index on scalar field.
By default, Milvus does not index a segment with less than 1,024 rows. To change this parameter, configure rootCoord.minSegmentSizeToEnableIndex in milvus.yaml.
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献15条内容
所有评论(0)