feat(search): index + return recording_date on search hits (#61)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ pub(crate) struct SearchHitView {
|
|||||||
pub brief_description: Option<String>,
|
pub brief_description: Option<String>,
|
||||||
#[schema(value_type = domain::Visibility)]
|
#[schema(value_type = domain::Visibility)]
|
||||||
pub visibility: String,
|
pub visibility: String,
|
||||||
|
pub recording_date: Option<String>,
|
||||||
pub snippet: Option<String>,
|
pub snippet: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +104,7 @@ pub(crate) async fn search_objects(
|
|||||||
object_name: h.object_name,
|
object_name: h.object_name,
|
||||||
brief_description: h.brief_description,
|
brief_description: h.brief_description,
|
||||||
visibility: h.visibility,
|
visibility: h.visibility,
|
||||||
|
recording_date: h.recording_date,
|
||||||
snippet: h.snippet,
|
snippet: h.snippet,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ pub struct SearchDocument {
|
|||||||
pub brief_description: Option<String>,
|
pub brief_description: Option<String>,
|
||||||
pub current_owner: Option<String>,
|
pub current_owner: Option<String>,
|
||||||
pub recorder: Option<String>,
|
pub recorder: Option<String>,
|
||||||
|
pub recording_date: Option<String>,
|
||||||
/// Filterable: "draft" | "internal" | "public".
|
/// Filterable: "draft" | "internal" | "public".
|
||||||
pub visibility: String,
|
pub visibility: String,
|
||||||
/// Flexible field values flattened to searchable text.
|
/// Flexible field values flattened to searchable text.
|
||||||
@@ -55,6 +56,7 @@ pub struct SearchHit {
|
|||||||
pub object_name: String,
|
pub object_name: String,
|
||||||
pub brief_description: Option<String>,
|
pub brief_description: Option<String>,
|
||||||
pub visibility: String,
|
pub visibility: String,
|
||||||
|
pub recording_date: Option<String>,
|
||||||
pub snippet: Option<String>,
|
pub snippet: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +235,7 @@ impl SearchClient {
|
|||||||
object_name: doc.object_name,
|
object_name: doc.object_name,
|
||||||
brief_description: doc.brief_description,
|
brief_description: doc.brief_description,
|
||||||
visibility: doc.visibility,
|
visibility: doc.visibility,
|
||||||
|
recording_date: doc.recording_date,
|
||||||
snippet,
|
snippet,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -367,6 +370,7 @@ pub async fn build_document(
|
|||||||
brief_description: object.brief_description.clone(),
|
brief_description: object.brief_description.clone(),
|
||||||
current_owner: object.current_owner.clone(),
|
current_owner: object.current_owner.clone(),
|
||||||
recorder: object.recorder.clone(),
|
recorder: object.recorder.clone(),
|
||||||
|
recording_date: object.recording_date.map(|d| d.to_string()),
|
||||||
visibility: object.visibility.as_str().to_owned(),
|
visibility: object.visibility.as_str().to_owned(),
|
||||||
fields_text,
|
fields_text,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ fn doc(id: &str, object_name: &str, fields_text: &[&str]) -> SearchDocument {
|
|||||||
brief_description: None,
|
brief_description: None,
|
||||||
current_owner: None,
|
current_owner: None,
|
||||||
recorder: None,
|
recorder: None,
|
||||||
|
recording_date: None,
|
||||||
visibility: "draft".to_string(),
|
visibility: "draft".to_string(),
|
||||||
fields_text: fields_text.iter().map(|s| s.to_string()).collect(),
|
fields_text: fields_text.iter().map(|s| s.to_string()).collect(),
|
||||||
}
|
}
|
||||||
@@ -66,6 +67,7 @@ async fn search_objects_returns_hits_with_highlight_filter_and_paging() {
|
|||||||
&["cast bronze with green patina"],
|
&["cast bronze with green patina"],
|
||||||
);
|
);
|
||||||
bronze_a.visibility = "public".to_string();
|
bronze_a.visibility = "public".to_string();
|
||||||
|
bronze_a.recording_date = Some("1962-04-03".to_string());
|
||||||
let mut bronze_b = doc(&b.to_string(), "Ceremonial bowl", &["bronze alloy rim"]);
|
let mut bronze_b = doc(&b.to_string(), "Ceremonial bowl", &["bronze alloy rim"]);
|
||||||
bronze_b.visibility = "public".to_string();
|
bronze_b.visibility = "public".to_string();
|
||||||
let mut bronze_c = doc(&c.to_string(), "Door fitting", &["bronze hinge"]);
|
let mut bronze_c = doc(&c.to_string(), "Door fitting", &["bronze hinge"]);
|
||||||
@@ -87,6 +89,7 @@ async fn search_objects_returns_hits_with_highlight_filter_and_paging() {
|
|||||||
"snippet must mark the match"
|
"snippet must mark the match"
|
||||||
);
|
);
|
||||||
assert!(snippet.contains(search::HL_POST));
|
assert!(snippet.contains(search::HL_POST));
|
||||||
|
assert_eq!(hit.recording_date.as_deref(), Some("1962-04-03"));
|
||||||
|
|
||||||
let public = client
|
let public = client
|
||||||
.search_objects("bronze", Some("public"), 0, 20)
|
.search_objects("bronze", Some("public"), 0, 20)
|
||||||
|
|||||||
Vendored
+1
@@ -603,6 +603,7 @@ export interface components {
|
|||||||
id: string;
|
id: string;
|
||||||
object_name: string;
|
object_name: string;
|
||||||
object_number: string;
|
object_number: string;
|
||||||
|
recording_date?: string | null;
|
||||||
snippet?: string | null;
|
snippet?: string | null;
|
||||||
visibility: components["schemas"]["Visibility"];
|
visibility: components["schemas"]["Visibility"];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user