From feed9e4eab9e18b7b23fbdc4702dc5097c04c62b Mon Sep 17 00:00:00 2001 From: Elie Gambache Date: Fri, 26 Jun 2026 12:35:29 +0300 Subject: [PATCH] feat(search): expose isBaseBook on LineHit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surface the indexed is_base_book flag on each LineHit so callers can correlate results — anchor every hit on its base line and nest matching commentaries under it. Defaults to false for source-compat with hits built outside the Lucene engine (e.g. the dense-hit factory). --- .../kdroidfilter/seforimlibrary/search/LuceneSearchEngine.kt | 3 ++- .../kdroidfilter/seforimlibrary/search/SearchSession.kt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/LuceneSearchEngine.kt b/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/LuceneSearchEngine.kt index b29acc66..eb85e842 100644 --- a/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/LuceneSearchEngine.kt +++ b/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/LuceneSearchEngine.kt @@ -558,7 +558,8 @@ class LuceneSearchEngine( lineIndex = meta.lineIndex, snippet = snippet, score = boostedScore, - rawText = raw + rawText = raw, + isBaseBook = meta.isBaseBook ) } // Re-sort by boosted score (descending) diff --git a/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/SearchSession.kt b/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/SearchSession.kt index 0f6f7e79..fa9736f9 100644 --- a/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/SearchSession.kt +++ b/search/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/search/SearchSession.kt @@ -62,6 +62,8 @@ data class SearchPage( * @property snippet HTML snippet with highlighted matching terms (contains `` tags) * @property score Relevance score (higher = more relevant). Includes boosts for base books. * @property rawText Original unprocessed text content of the line + * @property isBaseBook True if the line belongs to a base book (vs a commentary). Lets callers + * correlate results: anchor each hit on its base line and nest matching commentaries under it. */ data class LineHit( val bookId: Long, @@ -70,7 +72,8 @@ data class LineHit( val lineIndex: Int, val snippet: String, val score: Float, - val rawText: String + val rawText: String, + val isBaseBook: Boolean = false ) /**