Umbraco.Community.SearchSpellCheck 1.0.0-alpha

This is a prerelease version of Umbraco.Community.SearchSpellCheck.
dotnet add package Umbraco.Community.SearchSpellCheck --version 1.0.0-alpha                
NuGet\Install-Package Umbraco.Community.SearchSpellCheck -Version 1.0.0-alpha                
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="Umbraco.Community.SearchSpellCheck" Version="1.0.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Umbraco.Community.SearchSpellCheck --version 1.0.0-alpha                
#r "nuget: Umbraco.Community.SearchSpellCheck, 1.0.0-alpha"                
#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.
// Install Umbraco.Community.SearchSpellCheck as a Cake Addin
#addin nuget:?package=Umbraco.Community.SearchSpellCheck&version=1.0.0-alpha&prerelease

// Install Umbraco.Community.SearchSpellCheck as a Cake Tool
#tool nuget:?package=Umbraco.Community.SearchSpellCheck&version=1.0.0-alpha&prerelease                

SearchSpellCheck

Platform NuGet GitHub

A Lucene.Net-based spell checker for Umbraco

This project wouldn't exist without Lars-Erik Aabech who created a v7 version of this, which a lot of the work is based on.

How it works

alt text

On startup, this extension will index all the content in your site based on the IndexedFields settings. On every search, the extension will check the multi-word search term against the index and suggest the most likely words to the user.

Installation

The Umbraco v13 version of this package is available via NuGet.

To install the package, you can use either .NET CLI:

dotnet add package Umbraco.Community.SearchSpellCheck --version 1.0.0-alpha

or the NuGet Package Manager:

Install-Package Umbraco.Community.SearchSpellCheck -Version 1.0.0-alpha

Configuration

The package can be configured in appsettings.json

{
    "SearchSpellCheck": {
        "IndexName": "SpellCheckIndex",
        "IndexedFields": [ "nodeName" ],
        "BuildOnStartup": true,
        "RebuildOnPublish": true,
        "EnableLogging": false
    }
}

Settings

IndexName: The name of the Lucene index to be created. This is the also name of the folder in the App_Data folder that contains the Lucene index. By default it is SpellCheckIndex but this can be changed if you need a different naming convention.

IndexedFields: The alias(es) of fields to be indexed. This is a comma-separated list of field names. By default only the nodeName field is indexed. Currently, there is support for textstring, textareas, TinyMCE, Grid Layout and Block List Editor fields.

BuildOnStartup: Boolean indicating if you want the index to be populated on startup. Defaults to true.

RebuildOnPublish: Boolean indicating if you want the index to be populated on content being saved and published successfully. Defaults to true.

EnableLogging: Useful if you want to see what properties are being indexed and the content that is returned from the index. Defaults to false.

Usage

The package enables an ISuggestionService to be injected into your constructor:

private readonly IExamineManager _examineManager;
private readonly ISuggestionService _suggestionService;

public SearchService(
    IExamineManager examineManager,
    ISuggestionService suggestionService)
{
    _examineManager = examineManager;
    _suggestionService = suggestionService;
}

public string GetSuggestions(string searchTerm)
{
    return _suggestionService.GetSuggestion(searchTerm, suggestionAccuracy: 0.25f);
}

Which could in turn be returned in a view component or model:

if (model.TotalResults == 0)
{
    model.SpellCheck = _searchService.GetSuggestions(model.SearchTerm);
}

And then returned in the view:

@if (!string.IsNullOrEmpty(Model.SpellCheck))
{
    <p>Did you mean <a href="?s=@Model.SpellCheck"><em>@Model.SpellCheck</em></a>?</p>
}

License

Copyright © 2021-2025 Rick Butterfield, and other contributors

Licensed under the MIT License.

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-alpha 38 2/4/2025