feat: search body-text indexing with snippet extraction - #18
Merged
Conversation
… matches and improving ranking logic
…down, enhancing search index body content
…nd enhance SearchIndex tests for body content
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.
Summary
Extends the search index from title/description-only to full body-text matching, with a 2-line snippet surfaced when the match wouldn't otherwise be visible. Same client-side substring scoring, no build-step change, no new dependencies.
What's new
MarkdownPlainText.Extract(markdown, maxLength = 8000)inShellDocs.CoreStrips markdown/HTML noise down to searchable prose:
---…---)<Callout Title="x">body</Callout>→body)→alt[text](url)→text**bold**,*italic*→bold,italic)#prefixes (heading text kept)-,*,1.) and blockquote>maxLengthSearchEntry.Body(nullable) — populated forPageentries duringSearchIndex.FromGraph. Heading entries stay body-less (they anchor into the same page).SearchDialogscoring extendedBody substring match adds
+6; per-token body match adds+1. Both weighted lower than title/description/section so page name still wins on ties. Hard-reject still applies — every token must appear somewhere.Body-only match snippet
When the match comes from body (not title/section), the result surfaces a 2-line snippet centered on the first token hit:
Snippet is 150 chars, ellipsis prefix/suffix when trimmed, case-preserving.
.search-result-snippetCSS: 0.75rem muted,-webkit-line-clamp: 2for the two-line box.Out of scope (deliberate)
<mark>around the matched substring yet. Polish; its own follow-up.Test plan
dotnet build shelldocs.slnx— clean, 0 warnings, 0 errorsdotnet test shelldocs.slnx— 139 / 139 passing (+10 new: 8MarkdownPlainTextTests, 2SearchIndexTests)/docs/introductionrender clean —SearchEntryschema change (added optionalBodyfield with defaultnull) didn't regress anything downstreamCmd/Ctrl+K, search for a term that appears only in a page body (not any title or section) — result surfaces with a 2-line snippet under the title, URL navigates to the correct pageNew test coverage
MarkdownPlainTextTests(8):#prefixes (keeps heading text)maxLengthSearchIndexTests(+2):Files touched
src/ShellDocs.Core/MarkdownPlainText.cs(new)src/ShellDocs.Core/SearchIndex.cs—SearchEntry.Bodyfield,ExtractBodyFromFileinWalksrc/ShellDocs.Components/Chrome/SearchDialog.razor— body scoring, snippet extractionsrc/ShellDocs.Components/Chrome/SearchDialog.razor.css—.search-result-snippetstylingtests/ShellDocs.Tests/MarkdownPlainTextTests.cs(new)tests/ShellDocs.Tests/SearchIndexTests.cs(+2 tests)