This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

SearchIndexService Pennington.Search

Generates per-locale search index JSON. Each configured locale gets its own document bucket; the client fetches only the index for the active locale. Uses AsyncLazy for lazy, thread-safe computation. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — no manual watcher subscription needed.

Iterates TOC entries (which covers both markdown and Razor @page content) and fetches post-pipeline HTML via RenderedHtmlFetcher, so the index reflects what users actually see rather than pre-render markdown.

Constructors

.ctor

#
public SearchIndexService(
    IEnumerable<IContentService> contentServices,
    SearchIndexBuilder builder,
    SearchIndexOptions options,
    RenderedHtmlFetcher fetcher,
    LocalizationOptions localization,
    ILogger<SearchIndexService> logger);

Creates the service; the per-locale index is computed lazily on first request.

Parameters

contentServices IEnumerable<IContentService>
builder SearchIndexBuilder
options SearchIndexOptions
fetcher RenderedHtmlFetcher
localization LocalizationOptions
logger ILogger<SearchIndexService>

Methods

GetSearchIndexJsonAsync

#
public async Task<string> GetSearchIndexJsonAsync(string locale);

Returns the JSON array of search documents for the given locale. Returns "[]" when the locale has no indexed content (or is not registered).

Parameters

locale string

Returns

Task<string>

Pennington.Search.SearchIndexService

namespace Pennington.Search;

/// Generates per-locale search index JSON. Each configured locale gets its own document bucket; the client fetches only the index for the active locale. Uses AsyncLazy for lazy, thread-safe computation. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — no manual watcher subscription needed. Iterates TOC entries (which covers both markdown and Razor @page content) and fetches post-pipeline HTML via RenderedHtmlFetcher, so the index reflects what users actually see rather than pre-render markdown.
public class SearchIndexService
{
    /// Creates the service; the per-locale index is computed lazily on first request.
    
public SearchIndexService(
    IEnumerable<IContentService> contentServices,
    SearchIndexBuilder builder,
    SearchIndexOptions options,
    RenderedHtmlFetcher fetcher,
    LocalizationOptions localization,
    ILogger<SearchIndexService> logger);
/// Returns the JSON array of search documents for the given locale. Returns "[]" when the locale has no indexed content (or is not registered).
public async Task<string> GetSearchIndexJsonAsync(string locale);
}