Skip to content

Commit 61aa91b

Browse files
authored
perf: hnsw query (#4596)
* perf: hnsw query * check response embedding recall result
1 parent d9a4a5f commit 61aa91b

File tree

2 files changed

+9
-3
lines changed
  • docSite/content/zh-cn/docs/development/upgrading
  • packages/service/common/vectorStore/pg

2 files changed

+9
-3
lines changed

docSite/content/zh-cn/docs/development/upgrading/497.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ weight: 793
1212

1313
## ⚙️ 优化
1414

15-
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长
15+
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长。
16+
2. 调整 PG vector 查询语句,强制使用向量索引。
1617

1718
## 🐛 修复
1819

packages/service/common/vectorStore/pg/class.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ export class PgVectorCtrl {
192192
WITH relaxed_results AS MATERIALIZED (
193193
select id, collection_id, vector <#> '[${vector}]' AS score
194194
from ${DatasetVectorTableName}
195-
where team_id='${teamId}'
196-
AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
195+
where dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
197196
${filterCollectionIdSql}
198197
${forbidCollectionSql}
199198
order by score limit ${limit}
@@ -202,6 +201,12 @@ export class PgVectorCtrl {
202201
);
203202
const rows = results?.[3]?.rows as PgSearchRawType[];
204203

204+
if (!Array.isArray(rows)) {
205+
return {
206+
results: []
207+
};
208+
}
209+
205210
return {
206211
results: rows.map((item) => ({
207212
id: String(item.id),

0 commit comments

Comments
 (0)