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:
@@ -835,6 +835,7 @@ pub struct SemanticSearchResult {
|
||||
pub text_content: Option<String>,
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
pub similarity: Option<f64>,
|
||||
pub content: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
/// Result structure for child chunks
|
||||
@@ -2515,8 +2516,10 @@ impl PostgresDb {
|
||||
(start_time * fps)::bigint as start_frame, (end_time * fps)::bigint as end_frame, \
|
||||
fps, start_time, end_time, \
|
||||
COALESCE(summary_text, text_content, '') as summary, \
|
||||
text_content, \
|
||||
metadata, \
|
||||
(1 - (embedding <=> $1::vector)) as similarity \
|
||||
(1 - (embedding <=> $1::vector)) as similarity, \
|
||||
content \
|
||||
FROM {} \
|
||||
WHERE file_uuid = $2 AND chunk_type IN ('sentence', 'story_parent', 'llm_parent') AND embedding IS NOT NULL \
|
||||
ORDER BY embedding <=> $1::vector \
|
||||
@@ -2551,8 +2554,10 @@ impl PostgresDb {
|
||||
(start_time * fps)::bigint as start_frame, (end_time * fps)::bigint as end_frame, \
|
||||
fps, start_time, end_time, \
|
||||
COALESCE(summary_text, text_content, '') as summary, \
|
||||
text_content, \
|
||||
metadata, \
|
||||
(1 - (embedding <=> $1::vector)) as similarity \
|
||||
(1 - (embedding <=> $1::vector)) as similarity, \
|
||||
content \
|
||||
FROM {} \
|
||||
WHERE chunk_type IN ('sentence', 'story_parent', 'llm_parent') AND embedding IS NOT NULL \
|
||||
ORDER BY embedding <=> $1::vector \
|
||||
@@ -2584,7 +2589,8 @@ impl PostgresDb {
|
||||
COALESCE(summary_text, text_content, '') as summary, \
|
||||
text_content as text_content, \
|
||||
metadata, \
|
||||
1.0::float8 as similarity \
|
||||
1.0::float8 as similarity, \
|
||||
content \
|
||||
FROM {} \
|
||||
WHERE file_uuid = $1 AND chunk_id = $2 AND embedding IS NOT NULL \
|
||||
LIMIT 1",
|
||||
@@ -2615,7 +2621,8 @@ impl PostgresDb {
|
||||
COALESCE(summary_text, text_content, '') as summary, \
|
||||
text_content as text_content, \
|
||||
metadata, \
|
||||
1.0::float8 as similarity \
|
||||
1.0::float8 as similarity, \
|
||||
content \
|
||||
FROM {} \
|
||||
WHERE file_uuid = $1 AND chunk_id = $2 \
|
||||
LIMIT 1",
|
||||
|
||||
Reference in New Issue
Block a user