|
@@ -56,7 +56,7 @@ async function findMatchingContents(discipline, content) {
|
|
|
try {
|
|
|
// 使用余弦相似度进行内容向量匹配
|
|
|
const query = `
|
|
|
- SELECT title, id, content, file_url
|
|
|
+ SELECT title, id, content, file_url,
|
|
|
1 - (content_vector <#> $1::vector) AS contentSimilarity
|
|
|
FROM (select file_url, title, id, content, content_vector from knowledgefiles as a where top_dir_id in (select id from directory_files where $2 = '' or folder_name = ANY(string_to_array($2, ',')))) as a
|
|
|
ORDER BY contentSimilarity DESC
|