PyMilvus 2.5.x创建索引后无数据行被索引的问题求助
PyMilvus 2.5.x创建索引后无数据行被索引的问题求助
我正在用Python结合Milvus 2.5.x搭建RAG系统的文本嵌入索引,已经完成了集合的创建和数据填充。因为是研究项目,我的数据集规模很小:一个集合有500条数据,另一个只有53条。
我的当前代码配置如下:
from pymilvus import MilvusClient client = MilvusClient('../data/task_embeddings.db') client.load_collection('collection') client.drop_index('collection', 'problem_statement_embeddings') # 确保创建索引前环境干净 client.describe_index('collection', 'problem_statement_embeddings') # 检查上一步是否生效 index_params = MilvusClient.prepare_index_params() index_params.add_index( index_name='problem_statement_embeddings', field_name="vector", index_type="FLAT", metric_type="COSINE", ) client.create_index('collection', index_params, sync=True)
这段代码能正常运行,但之后我用client.describe_index('collection', 'problem_statement_embeddings')检查索引状态时,得到了如下输出:
{'index_type': 'FLAT', 'metric_type': 'COSINE', 'dim': '768', 'field_name': 'vector', 'index_name': 'problem_statement_embeddings', 'total_rows': 0, 'indexed_rows': 0, 'pending_index_rows': 0, 'state': 'Finished'}
结果显示没有任何数据行被索引。不过我运行搜索查询时还是能得到返回结果,考虑到当前数据集的规模,可能暂时不会有性能问题,但我还是想搞清楚这背后的原因,避免后续项目扩展时出现意外的异常行为。
我已经在Milvus的官方仓库中提交了这个问题。
备注:内容来源于stack exchange,提问作者Liqs




