perf: hnsw query (#4596)
Some checks failed
Deploy doc image to cf / deploy-production (push) Has been cancelled
Deploy doc image by kubeconfig / build-fastgpt-docs-images (push) Has been cancelled
Build FastGPT images in Personal warehouse / build-fastgpt-images (push) Has been cancelled
Deploy doc image by kubeconfig / update-docs-image (push) Has been cancelled

* perf: hnsw query

* check response embedding recall result
This commit is contained in:
Archer 2025-04-18 19:31:02 +08:00 committed by GitHub
parent d9a4a5f3e7
commit 61aa91b3aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -12,7 +12,8 @@ weight: 793
## ⚙️ 优化
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长
1. Doc2x 文档解析,增加报错信息捕获,增加超时时长。
2. 调整 PG vector 查询语句,强制使用向量索引。
## 🐛 修复

View File

@ -192,8 +192,7 @@ export class PgVectorCtrl {
WITH relaxed_results AS MATERIALIZED (
select id, collection_id, vector <#> '[${vector}]' AS score
from ${DatasetVectorTableName}
where team_id='${teamId}'
AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
where dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
${filterCollectionIdSql}
${forbidCollectionSql}
order by score limit ${limit}
@ -202,6 +201,12 @@ export class PgVectorCtrl {
);
const rows = results?.[3]?.rows as PgSearchRawType[];
if (!Array.isArray(rows)) {
return {
results: []
};
}
return {
results: rows.map((item) => ({
id: String(item.id),