Coder Social home page Coder Social logo

lunr-core's Introduction

lunr-core

A port of lunr.js to .NET Core. Lunr is a bit like Solr, but much smaller and not as bright.

.NET Core

TODO / up for grabs

  • Multilingual support (lunr has optional support that remains to be ported)
  • Documentation (adapted from lunr docs)

Example

A very simple search index can be created using the following:

var index = await Index.Build(async builder =>
{
    builder
        .AddField("title")
        .AddField("body");

    await builder.Add(new Document
    {
        { "title", "Twelfth-Night" },
        { "body", "If music be the food of love, play on: Give me excess of it…" },
        { "author", "William Shakespeare" },
        { "id", "1" },
    });
});

Then searching is as simple as:

await foreach (Result result in index.Search("love"))
{
    // do something with that result
}

This returns a list of matching documents with a score of how closely they match, the search query as well as any associated metadata about the match:

new List<Result>
{
    new Result(
        documentReference: "1",
        score: 0.3535533905932737,
        matchData: new MatchData(
            term: "love",
            field: "body"
        )
    )
}

Description

Lunr-core is a small, full-text search library for use in small applications. It indexes documents and provides a simple search interface for retrieving documents that best match text queries. It is 100% compatible with lunr.js, meaning that an index file prepared on the server with lunr-core can be used on the client using lunr.js.

Why

Lunr-core is suitable for small applications that require a simple search engine but without the overhead of a full-scale search engine such as Lucene. Its compatibility with lunr.js also opens up some interesting client-side search scenarios.

Features

  • Soon: Full text search support for 14 languages
  • Boost terms at query time or boost entire documents at index time
  • Scope searches to specific fields
  • Fuzzy term matching with wildcards or edit distance
  • No runtime dependencies beyond SDK, BCL AsyncInterfaces and System.Text.Json

Credits

lunr-core's People

Contributors

bleroy avatar danielcrenna avatar iamcarbon avatar xoofx avatar aidapsibr avatar am11 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.