Skip to content
A lightweight zero-dependency C# port of the Fuse.js fuzzy-search library created by @krisk at https://github.com/krisk/Fuse
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Fuse.NET
.gitignore
Fuse.NET.sln Add support for Nuget restoration Dec 22, 2019
LICENSE
LICENSE.ORIGINAL
README.md
icon.png
logo.png

README.md

Introduction

A lightweight zero-dependency C# port of the Fuse.js fuzzy-search library created by @krisk at https://github.com/krisk/Fuse

I ported this to C# because I couldn't find anything like it, and because I love Fuse.js.

Licenses

You can find the original license in the LICENSE.ORIGINAL file, and the license for this derivative work in the LICENSE file.

Documentation

At this time there is no documentation for Fuse.NET, but as it is a direct port of Fuse.js, you can find all the information you need on the Fuse.js website at https://fusejs.io/

Example Usage

public struct Book
{
    public string title;
    public string author;
}

// This test data was taken from the fixtures in Fuse.js.
var input = new List<Book>();

input.Add(new Book
{
    title = "The Code of The Wooster",
    author = "Bob James"
});

input.Add(new Book
{
    title = "The Wooster Code",
    author = "Rick Martin"
});

input.Add(new Book
{
    title = "The Code",
    author = "Jimmy Charles"
});

input.Add(new Book
{
    title = "Old Man's War",
    author = "John Scalzi"
});

input.Add(new Book
{
    title = "The Lock Artist",
    author = "Steve Hamilton"
});

var opt = new FuseOptions();

opt.includeMatches = true;
opt.includeScore = true;

// Here we search through a list of `Book` types but you could search through just a list of strings.
var fuse = new Fuse<Book>(input, opt);

fuse.AddKey("title");
fuse.AddKey("author");

var output = fuse.Search("woo");

output.ForEach((a) =>
{
    Debug.Log(a.item.title + ": " + a.item.author);
    Debug.Log("Score: " + a.score);

    if (a.matches != null)
    {
        a.matches.ForEach((b) =>
        {
            Debug.Log("{Match}");
            Debug.Log(b.key + ": " + b.value + " (Indicies: " + b.indicies.Count + ")");
        });
    }
});

Installation

Using Nuget:

Install-Package Fuse.NET -Version 0.1.0

Contributing

Contributions are welcome, if you have one to make please don't hesitate to create a pull request.

You can’t perform that action at this time.