Skip to content

feat(search): highlight the found line by meaning, without the query's words - #684

Merged
kdroidFilter merged 2 commits into
masterfrom
feat/semantic-highlight-everywhere
Oct 12, 2026
Merged

kdroidFilter merged 2 commits into
masterfrom
feat/semantic-highlight-everywhere

Conversation

@kdroidFilter

Copy link
Copy Markdown
Owner

A search now highlights the way the meaning finds it: in the found line alone, the passage closest in meaning, and none of the query's words. This applies to the results' snippets, their preview and the reader's smart find. A quoted search is unchanged: its words, everywhere.

Changes

  • HybridSearchEngine
    • highlightsByMeaning is true for any non-quoted query.
    • Snippets are first shown without bold, then each hit's snippet is laid out on the passage of its found line, not of the neighbors that a short line's snippet carries.
  • Preview (PassagePreview): neighbor lines are no longer highlighted; the found line shows the passage.
  • Smart find: follows the same rule through SearchEngine.highlights (one logic for every view).
  • seforim-semantic 0.5.0: finds that passage in ~6 ms per result instead of ~70. A static distillation of the model ranks the clauses; the model reranks only the best 2.
  • SeforimLibrary: bumped to include the highlightsByMeaning hook and the hit line bounds (feat(search): highlight a found line by meaning, without the query's words SeforimLibrary#132).
  • SearchBench: reports the refine cost per result and the process memory.

Measured (SearchBench, pages of 25, dev DB)

value
highlight cost per result ~4 ms (goal: ≤ 10 ms)
native memory +10 MB vs current master
static table (heap) 18.6 MB, by construction (not measured on the heap)
same passage as embedding every clause 89.7 %

Tests

  • ktlint and detekt pass.
  • jvmTest: everything passes except WidgetSizesScreenshotTest and CopyWithSourceE2ETest.talmud_multi_line_selection_trims_both_ends, which fail the same way on current master (unrelated to this change).
  • Not checked visually in the running app.

…s words

A search highlights the way the meaning finds it: in the found line alone, the
passage closest in meaning, and none of the query's words, in the results'
snippets, their preview and the smart find. A quoted search keeps its words.

- HybridSearchEngine: highlightsByMeaning for any non-quoted query; snippets
  shown without bold, then every hit's snippet laid out on the passage of its
  found line (not of the neighbors a short line's snippet carries).
- Preview: the neighbors are no longer highlighted, the found line shows the
  passage.
- seforim-semantic 0.5.0 finds that passage in ~6 ms per result instead of ~70
  (a static distillation ranks the clauses, the model reranks the best 2):
  ~4 ms per result end to end, +10 MB native memory.
- SeforimLibrary with the highlightsByMeaning hook (#132).
- SearchBench reports the refine cost per result and the process memory.

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
…ight-everywhere

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>

# Conflicts:
#	gradle/libs.versions.toml
@kdroidFilter
kdroidFilter merged commit 56bb1c3 into master Oct 12, 2026
8 of 9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant