Repository navigation
Conversation
dblock
force-pushed
the
dblock/highlighting
branch
from
October 17, 2026 12:00
7d8641d to
8b956f3
Compare
Danger ReportNo issues found. |
dblock
force-pushed
the
dblock/highlighting
branch
2 times, most recently
from
October 18, 2026 14:27
7fb273d to
cd1c850
Compare
Map sampled query term matches back to original grapheme ranges, return plain and escaped HTML snippets, and expose an optional document helper without changing search result types. No database reads or index migration are needed. Implements mongoid#11 originally requested by @luizkowalski. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dblock
force-pushed
the
dblock/highlighting
branch
from
October 18, 2026 14:35
cd1c850 to
be7b73d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11.
Adds
fulltext_search_with_highlightsso callers receive documents, scores, and complete highlighted field values together:Results preserve search ordering, criteria, filters, and
max_results. Existingfulltext_searchbehavior is unchanged.fieldsselects indexed fields to display; omitted, it includes all fields in the selected index. Unknown fields raiseArgumentError, andindex:selects among multiple indexes.Highlights contain full strings, never snippets. Arrays preserve order and nil elements; nil scalars stay nil. Unmatched text is escaped and retained, including titles when another field matched. Default markup is
<b>...</b>; a block can customize it:The block receives an HTML-escaped match after overlapping and adjacent matches are merged. Its returned markup is inserted verbatim and must be trusted; surrounding text is escaped automatically. Output is intended for HTML element content, not attributes, scripts, or URLs.
Also adds
document.fulltext_highlightsfor already-loaded documents and a standalone highlighter without a Mongoid/database dependency. Computed readers, arrays, Unicode normalization, and localized fields are covered. No positional index storage, document mutation, or index rebuild is required.Matching follows the existing bounded ngrams, not exact substring matching: partial-word highlights and unmarked portions are possible. Stale indexes can return documents without current highlights. Applications must explicitly choose safe fields to display.
Includes regression coverage and README examples. Rebased onto current master.
Prepared by an AI on behalf of @dblock.