https://github.com/bleroy/lunr-core
Lunr-core is a small, full text search library for use in small applications. It's a .NET port of LUNR.js.
https://github.com/bleroy/lunr-core
Last synced: 8 months ago
JSON representation
Lunr-core is a small, full text search library for use in small applications. It's a .NET port of LUNR.js.
- Host: GitHub
- URL: https://github.com/bleroy/lunr-core
- Owner: bleroy
- License: mit
- Created: 2020-06-27T21:41:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-25T19:21:48.000Z (11 months ago)
- Last Synced: 2025-05-08T14:52:10.501Z (8 months ago)
- Language: C#
- Homepage:
- Size: 1.56 MB
- Stars: 568
- Watchers: 19
- Forks: 25
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- fucking-awesome-dotnet - Lunr-Core - Lunr-core is a small, full text search library for use in small applications. It's a .NET port of LUNR.js. (Search / GUI - other)
- awesome-dotnet - Lunr-Core - Lunr-core is a small, full text search library for use in small applications. It's a .NET port of LUNR.js. (Search / GUI - other)
- awesome-dotnet - Lunr-Core - core?style=social&label=)|Lunr-core is a small, full text search library for use in small applications. It's a .NET port of LUNR.js. (Identifiers)
README
# lunr-core
Lunr-core is a small, full text search library for use in small applications.
It's a port of [lunr.js](https://lunrjs.com/guides/getting_started.html) to .NET Core.
Lunr is a bit like Solr, but much smaller and not as bright.

## TODO / up for grabs
* Multilingual support (lunr has optional support that remains to be ported)
* Documentation (adapted from [lunr docs](https://lunrjs.com/guides/getting_started.html))
## Example
A very simple search index can be created using the following:
```csharp
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:
```csharp
await foreach (Result result in index.Search("love"))
{
// do something with that result
}
```
This returns a list of matching documents with a [score](https://lunrjs.com/guides/searching.html#scoring) of how closely they match, the search query as well as any associated metadata about the match:
```csharp
new List
{
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](https://lunrjs.com/guides/getting_started.html), 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
* Original code by [Oliver Nightingale](https://github.com/olivernn) and contributors, ported to .NET Core by [Bertrand Le Roy](https://github.com/bleroy).
* Icon adapted from https://commons.wikimedia.org/wiki/File:Internal_Structure_of_the_Moon.JPG by Iqbal Mahmud under Creative Commons Attribution Share Alike 4.0 International.
* Perf tests use a [word list by Sindre Sorhus](https://github.com/sindresorhus/word-list).