|
@@ -57,9 +57,9 @@ async function findMatchingContents(discipline, content) {
|
|
|
try {
|
|
|
// 使用余弦相似度进行内容向量匹配
|
|
|
const query = `
|
|
|
- SELECT title, id, content, file_url,
|
|
|
+ SELECT title, id, content, file_url, file_type,
|
|
|
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_type, 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;
|
|
|
`;
|
|
@@ -91,9 +91,9 @@ async function findMatchingContentsPage2(discipline, content, grade, page) {
|
|
|
try {
|
|
|
// 使用余弦相似度进行内容向量匹配
|
|
|
const query = `
|
|
|
- SELECT title, id, content, file_url,
|
|
|
+ SELECT title, id, content, file_url, file_type,
|
|
|
1 - (content_vector <#> $1::vector) AS contentSimilarity
|
|
|
- FROM (select file_url, title, id, content, content_vector from knowledgefiles as a
|
|
|
+ FROM (select file_type, 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
|
|
@@ -118,9 +118,9 @@ async function findMatchingContentsPage(discipline, content, page) {
|
|
|
try {
|
|
|
// 使用余弦相似度进行内容向量匹配
|
|
|
const query = `
|
|
|
- SELECT title, id, content, file_url,
|
|
|
+ SELECT title, id, content, file_url, file_type,
|
|
|
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
|
|
|
+ FROM (select file_type, 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;
|