feat(search): surface summary snippet when summary matched the query
Add a summary_snippet column to findEnrichmentData using ts_headline on documents.summary, only when the summary's tsvector matches the query. Expose it via SearchMatchData.summarySnippet / summaryOffsets and render a "Zusammenfassung" / "Summary" / "Resumen" labelled row in the document list — identical treatment to the transcription snippet row. Fixes the case where a document appeared in search results with no visible match explanation (e.g. searching "frucht" found a document whose summary mentioned "Früchte"). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #242.
This commit is contained in:
@@ -125,7 +125,7 @@ class DocumentControllerTest {
|
||||
.status(DocumentStatus.UPLOADED)
|
||||
.build();
|
||||
var matchData = new org.raddatz.familienarchiv.dto.SearchMatchData(
|
||||
"Er schrieb einen langen Brief", List.of(), false, List.of(), List.of(), List.of());
|
||||
"Er schrieb einen langen Brief", List.of(), false, List.of(), List.of(), List.of(), null, List.of());
|
||||
when(documentService.searchDocuments(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()))
|
||||
.thenReturn(DocumentSearchResult.withMatchData(List.of(doc), Map.of(docId, matchData)));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class DocumentSearchResultTest {
|
||||
@Test
|
||||
void withMatchData_exposes_match_data_map() {
|
||||
UUID id = UUID.randomUUID();
|
||||
SearchMatchData data = new SearchMatchData("snippet", List.of(), false, List.of(), List.of(), List.of());
|
||||
SearchMatchData data = new SearchMatchData("snippet", List.of(), false, List.of(), List.of(), List.of(), null, List.of());
|
||||
DocumentSearchResult result = DocumentSearchResult.withMatchData(List.of(doc(id)), Map.of(id, data));
|
||||
|
||||
assertThat(result.matchData()).containsKey(id);
|
||||
|
||||
@@ -10,7 +10,7 @@ class SearchMatchDataTest {
|
||||
|
||||
@Test
|
||||
void transcription_snippet_is_nullable() {
|
||||
SearchMatchData data = new SearchMatchData(null, List.of(), false, List.of(), List.of(), List.of());
|
||||
SearchMatchData data = new SearchMatchData(null, List.of(), false, List.of(), List.of(), List.of(), null, List.of());
|
||||
|
||||
assertThat(data.transcriptionSnippet()).isNull();
|
||||
}
|
||||
@@ -35,6 +35,8 @@ class SearchMatchDataTest {
|
||||
true,
|
||||
List.of(),
|
||||
List.of(),
|
||||
List.of(),
|
||||
null,
|
||||
List.of()
|
||||
);
|
||||
|
||||
@@ -58,7 +60,9 @@ class SearchMatchDataTest {
|
||||
false,
|
||||
List.of(),
|
||||
List.of(),
|
||||
List.of(offset)
|
||||
List.of(offset),
|
||||
null,
|
||||
List.of()
|
||||
);
|
||||
assertThat(data.snippetOffsets()).containsExactly(offset);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user