feat: pg vector 0.8.0;perf: app pdf enhance parse (#3962)

* perf: app pdf enhance parse

* feat: pg vector 0.8.0

* update schema default

* model sort and default image

* perf: i18n

* perf: ui tip
This commit is contained in:
Archer
2025-03-04 13:43:50 +08:00
committed by archer
parent adf5377ebe
commit 54eb5c0547
33 changed files with 181 additions and 66 deletions

View File

@@ -164,34 +164,22 @@ export class PgVectorCtrl {
}
try {
// const explan: any = await PgClient.query(
// `BEGIN;
// SET LOCAL hnsw.ef_search = ${global.systemEnv?.pgHNSWEfSearch || 100};
// EXPLAIN ANALYZE select id, collection_id, vector <#> '[${vector}]' AS score
// from ${DatasetVectorTableName}
// where team_id='${teamId}'
// AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
// ${forbidCollectionSql}
// order by score limit ${limit};
// COMMIT;`
// );
// console.log(explan[2].rows);
const results: any = await PgClient.query(
`
BEGIN;
`BEGIN;
SET LOCAL hnsw.ef_search = ${global.systemEnv?.pgHNSWEfSearch || 100};
select id, collection_id, vector <#> '[${vector}]' AS score
from ${DatasetVectorTableName}
where team_id='${teamId}'
AND dataset_id IN (${datasetIds.map((id) => `'${String(id)}'`).join(',')})
${filterCollectionIdSql}
${forbidCollectionSql}
order by score limit ${limit};
SET LOCAL hnsw.iterative_scan = relaxed_order;
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(',')})
${filterCollectionIdSql}
${forbidCollectionSql}
order by score limit ${limit}
) SELECT id, collection_id, score FROM relaxed_results ORDER BY score;
COMMIT;`
);
const rows = results?.[2]?.rows as PgSearchRawType[];
const rows = results?.[3]?.rows as PgSearchRawType[];
return {
results: rows.map((item) => ({