lsc 6 maanden geleden
bovenliggende
commit
69b60618af
1 gewijzigde bestanden met toevoegingen van 4 en 3 verwijderingen
  1. 4 3
      pbl.js

+ 4 - 3
pbl.js

@@ -91,9 +91,9 @@ async function findMatchingContentsPage2(discipline, content, grade, page) {
     try {
         // 使用余弦相似度进行内容向量匹配
         const query = `
-            SELECT id, content,
+            SELECT title, id, content, file_url,
                    1 - (content_vector <#> $1::vector) AS contentSimilarity
-            FROM (select id, content, content_vector from knowledgefiles as a 
+            FROM (select file_url, title, id, content, content_vector from knowledgefiles as a 
             where ($2 = '' or a.parent_arr && (SELECT ARRAY_AGG(id)::text[] FROM directory_files WHERE folder_name = ANY(string_to_array($2, ',')))) 
             AND ($3 = '' or a.parent_arr && (SELECT ARRAY_AGG(id)::text[] FROM directory_files WHERE folder_name = ANY(string_to_array($3, ','))))) as a
             ORDER BY contentSimilarity DESC
@@ -120,7 +120,8 @@ async function findMatchingContentsPage(discipline, content, page) {
         const query = `
             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
+            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
             LIMIT 5 OFFSET $3;
         `;