Skip to content

feat(search): one highlighting logic for results, preview and smart find - #635

Merged
kdroidFilter merged 3 commits into
devfrom
fix/search-highlighting
Oct 10, 2026
Merged

kdroidFilter merged 3 commits into
devfrom
fix/search-highlighting

Conversation

@kdroidFilter

Copy link
Copy Markdown
Owner

Depends on kdroidFilter/SeforimLibrary#116 (the submodule points to its branch) and seforim-semantic 0.4.1 (published, SeforimEmbedding#2 merged).

Highlighting

One logic, in the search engine, for the three places a search is highlighted:

  • Results list: snippets lead with their matches (the list shows two lines), starting in the found line.
  • Preview pane: the same words as the snippet, through SearchEngine.highlightRanges / highlights. It used to take the snippet's bold words and match them as substrings in every line (נבראו half-highlighted for ברא).
  • Reader's smart find: the hybrid search scoped to the book, so the lines holding the query's words are found and highlighted as words. It used to take the nearest lines by meaning only (verse א wasn't highlighted for בראשית ברא).

Rules (see SeforimLibrary#116): whole words; the word itself, prefixed or inflected; never a loose dictionary variant (עם for כל); acronyms with any quotes; consecutive words as one span; the passage closest in meaning only where none of the query's words is.

Quit

Quitting waited up to 10 s for the Drive backup on the UI thread (reproduced: thread dump of a real quit). It now runs in a shutdown hook; QuitBackupTest checks it in a child JVM exiting through System.exit. Confirmed fast on a real quit.

Validation

  • 539 app tests (search, reader, find, Drive backup); ktlint + detekt clean.
  • Real index, 31 queries × 25 results, lexical and hybrid: 0 result without bold, 0 cut word.
  • Results page latency unchanged.
  • App run with the E2E harness: list, preview and smart find highlight the same words.

- Results' snippets, their preview pane and the reader's smart find all
  highlight through SearchEngine.highlightRanges / highlights: whole words for
  the query (and its inflections), consecutive ones as one span; a found line
  without them gets the passage closest in meaning. The preview no longer
  guesses the passage from the snippet's bold, nor matches substrings
- Smart find in a book is the hybrid search scoped to the book: the lines with
  the query's words come first-class, highlighted as words
- Meaning-based snippets are refined only for lines without the query's words
- seforim-semantic 0.4.1 (book-filtered dense search); SeforimLibrary with the
  shared highlighter

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
The backup on quit ran on the UI thread before the windows closed, up to 10 s
of network round trips after a session with changes (every search records the
history). It now runs in a shutdown hook: the windows close at once and the
process finishes the upload out of sight, within the same limit. QuitBackupTest
checks it in a child JVM exiting through System.exit, as the app does.

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
@kdroidFilter
kdroidFilter merged commit a64afe0 into dev Oct 10, 2026
2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2026
@kdroidFilter

Copy link
Copy Markdown
Owner Author

Added: the smart find (✨) shows each line's passage closest in meaning beside the query's words again (the embedding looked unused). Depends now on kdroidFilter/SeforimLibrary#117 too; the submodule points to its branch.

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