feat: add source prefix to search results

- Add [OCR], [ASRX], [ASRX+OCR] prefix to text_content
- Add content field to SemanticSearchResult struct
- Update SQL queries to include content field
- Helps users distinguish the source of search results
This commit is contained in:
Accusys
2026-07-19 14:06:06 +08:00
parent 5e83ee7dac
commit 87aa7e0c40
10 changed files with 3947 additions and 6 deletions
+23 -2
View File
@@ -459,6 +459,27 @@ pub async fn smart_search(
pg.summary.clone()
};
// Determine source prefix based on content field
let source_prefix = if let Some(ref content) = pg.content {
let text = content.get("text").and_then(|t| t.as_str()).unwrap_or("");
let ocr_text = content.get("ocr_text").and_then(|t| t.as_str()).unwrap_or("");
let has_asrx = !text.trim().is_empty();
let has_ocr = !ocr_text.trim().is_empty();
if has_asrx && has_ocr {
"[ASRX+OCR] "
} else if has_asrx {
"[ASRX] "
} else if has_ocr {
"[OCR] "
} else {
""
}
} else {
""
};
final_results.push(SearchResult {
id: 0,
file_uuid: pg.file_uuid.clone(),
@@ -470,8 +491,8 @@ pub async fn smart_search(
start_time: pg.start_time,
end_time: pg.end_time,
raw_text: None,
summary: Some(pg.summary),
text_content: pg.text_content.clone(),
summary: Some(format!("{}{}", source_prefix, display_text)),
text_content: Some(format!("{}{}", source_prefix, pg.text_content.clone().unwrap_or_default())),
metadata: pg.metadata.clone(),
similarity: Some(mr.score),
file_name: None,