FLAT索引
- 暴力搜索,召回率100%,全表扫描。
- FLAT不压缩向量,是唯一保证精确搜索结果的索引。
- FLAT是准确的,采用了穷尽的搜索方法。
- FLAT也是最慢的索引。并不适合查询大量向量数据。
- FLAT索引不需要任何参数。
- 使用它不需要数据训练。
- 创建FLAT索引瞬间完成,创建其他类型的索引需要耗费一定的时间。
使用Attu创建FLAT索引


python代码通过pymilvus创建FLAT索引
python
from pymilvus import (
connections,
Collection
)
collection_name = "test_collection"
host = "192.168.171.130"
port = 19530
username = ""
password = ""
connections.connect("default", host=host, port=port, user=username, password=password)
collection = Collection(collection_name, consistency_level="Bounded", shards_num=1)
index_params = {
"index_type": "FLAT",
"metric_type": "L2",
"params": {}
}
collection.create_index(
field_name="embeddings",
index_params=index_params,
index_name="idx_em"
)
print("done")
# collection加载到内存
collection.load()
