DeweySearch.Web 0.1.1

dotnet add package DeweySearch.Web --version 0.1.1
                    
NuGet\Install-Package DeweySearch.Web -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeweySearch.Web" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeweySearch.Web" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="DeweySearch.Web" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeweySearch.Web --version 0.1.1
                    
#r "nuget: DeweySearch.Web, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DeweySearch.Web@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DeweySearch.Web&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=DeweySearch.Web&version=0.1.1
                    
Install as a Cake Tool

DeweySearch

A standalone, dependency-free static search index. Build a sharded, Pagefind-style inverted index at build time in C#; query it entirely client-side with a tiny JavaScript client that fetches only the shards a query touches. No server, no service, no third-party runtime.

DeweySearch is the search engine extracted from Pennington, with zero ties to any content model — feed it documents, get back JSON artifacts.

How it works

documents ──▶ IndexBuilder.Build() ──▶ SearchIndex ──▶ ToFiles()
                                                          │
                                   index.json, t-{prefix}.json, f-{docId}.json
                                                          │
                                                          ▼
                                   DeweySearchEngine (dewey-search.js)  ◀── browser query

The C# builder and the JS client share a byte-for-byte tokenizer/stemmer contract so that build-time index keys and client-time query terms always agree. Both are pinned by the shared fixtures under conformance/.

Packages

Package What it is
DeweySearch (NuGet) The BCL-only index builder, tokenizer, stemmer, and wire records.
DeweySearch.Web (NuGet) ASP.NET Core static-asset delivery of the client at _content/DeweySearch.Web/dewey-search.js.

Building an index (C#)

using DeweySearch;

var documents = new[]
{
    new SearchDocument(
        Url: "/guide/routing/",
        Title: "Routing Guide",
        Description: "Configure routing for your pages",
        Headings: "Routes Wildcards",
        Body: "Long-form plain-text body…",
        Priority: 5,
        Facets: new Dictionary<string, string[]>
        {
            ["section"] = ["Guides"],
            ["tag"]     = ["routing", "beginner"],
        }),
};

var index = new IndexBuilder(new IndexOptions { ShardPrefixLength = 2 }).Build(documents);

// Write the artifacts wherever the client will fetch them from.
foreach (var (name, bytes) in index.ToFiles())
{
    File.WriteAllBytes(Path.Combine("wwwroot/search/en", name), bytes);
}

Facets are an open dictionary — any dimension you put on a document (section, tag, area, author, …) is interned, id-mapped, and shipped in the manifest for client-side filtering. DeweySearch has no built-in notion of what a facet means.

Querying (JavaScript)

<script src="/_content/DeweySearch.Web/dewey-search.js"></script>
<script>
  const engine = new DeweySearchEngine('/search/en'); // directory holding the artifacts
  const results = await engine.search('routing');      // [{ docId, score, fields }, …]
  const F = DeweySearchEngine.FieldFlags;
  for (const { docId, fields } of results) {
    const doc = engine.docEntry(docId);                // title, url, facets
    // `fields` is the OR of fields the query matched in; skip the body snippet on a heading hit.
    const headingHit = fields & (F.Title | F.Heading);
    const fragment = headingHit ? null : await engine.loadFragment(docId); // body excerpt, on demand
  }
</script>

The client fetches index.json once, then only the term-prefix shards a query touches and the fragments for results actually shown — the whole index is never downloaded. It supports BM25 ranking, field boosts (title/heading/description/body), prefix completion, bounded typo-tolerant fuzzy matching, and synonyms.

Each result carries fields — the OR of the field flags the match landed in (DeweySearchEngine.FieldFlags: Title, Heading, Description, Body) — so the UI can branch on where a query hit, for example dropping the body snippet when a result already matched in its heading.

Repository layout

  • src/DeweySearch/ — the index builder and the cross-language tokenizer/stemmer (BCL-only).
  • src/DeweySearch.Web/ — Razor Class Library that ships the JS client as a static web asset.
  • js/ — the canonical dewey-search.js (shipped via DeweySearch.Web) and its contract tests.
  • conformance/ — shared fixtures both runtimes assert against.
  • tests/DeweySearch.Tests/ — C# unit + contract tests.

Build & test

dotnet test DeweySearch.slnx       # C# engine + cross-language contract
cd js && node --test         # JS client + same contract fixtures

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DeweySearch.Web:

Package Downloads
Pennington.UI

Razor component library for Pennington — navigation, code blocks, and content display

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 94 5/23/2026
0.1.0 54 5/23/2026