You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Supabase vecs库查询HNSW索引集合时遇ivfflat.probes错误

解决Supabase vecs库HNSW索引查询时触发ivfflat参数错误的问题

临时解决方案

1. 查询时显式指定HNSW索引

修改查询代码,通过query方法的index参数指定你创建的HNSW索引名称(vecs默认创建的HNSW索引命名格式为{集合名}_hnsw,你的场景下就是my_embeddings_hnsw):

results = collection.query(
    data=query,
    limit=top_k,
    ef_search=200,
    skip_adapter=False,
    include_metadata=True,
    include_value=True,
    index="my_embeddings_hnsw"  # 强制指定使用HNSW索引
)

2. 重新创建集合并确认索引生效

若不确定索引是否正确创建,可先删除旧集合,重新执行创建、插入、建索引流程:

# 删除已存在的集合
vx.delete_collection(name="my_embeddings")
# 重新创建集合
docs = vx.get_or_create_collection(
    name="my_embeddings",
    adapter=embedding_adapter,
)
docs.upsert(records=records)
# 重建HNSW索引
docs.create_index(
    method=IndexMethod.hnsw,
    measure=IndexMeasure.cosine_distance,
    index_arguments=IndexArgsHNSW(m=16, ef_construction=64),
)

问题原因

vecs库的查询逻辑默认会尝试设置ivfflat索引的probes参数,但当集合仅存在HNSW索引时,这条针对ivfflat的配置语句会触发PostgreSQL语法错误——HNSW索引不需要ivfflat.probes这类参数,数据库无法识别该配置指令。

该问题本质是库的索引类型检测逻辑未正确识别当前集合使用的是HNSW索引,导致错误加载了ivfflat相关的参数设置代码。显式指定索引可强制查询走HNSW路径,规避ivfflat的无效配置操作。

内容的提问来源于stack exchange,提问作者KZiovas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 04:12:03