TantivyDotNet
Fast embedded full-text search for .NET, powered by Tantivy, the Rust search engine library. Install one NuGet package and get Lucene-style indexing and search, with no Rust toolchain and no server to run.
dotnet add package TantivyDotNet --prerelease
using TantivyDotNet;
var schema = new SchemaBuilder()
.AddStringField("id", stored: true)
.AddTextField("title", stored: true)
.AddU64Field("year", stored: true, fast: true)
.Build();
using var index = SearchIndex.CreateInRam(schema);
using (var writer = index.CreateWriter())
{
writer.AddDocument("""{"id": "b1", "title": "Of Mice and Men", "year": 1937}""");
writer.Commit();
}
using var searcher = index.CreateSearcher();
foreach (var hit in searcher.Search("title:mice"))
Console.WriteLine(hit.Document.GetString("title"));
- Features: custom analyzers, a query language and queries built in code, snippets, facets, multi-key sorting with cursor paging, Elasticsearch-style aggregations, score explanations, merge control and shared searchers.
- Platforms: .NET 10 and 11 on Windows x64, Linux x64/arm64 (glibc) and macOS x64/arm64. Trimming- and NativeAOT-compatible.
- Speed: indexes 2-3× faster than Lucene.NET 4.8 and answers most queries 4-7× faster on the benchmark.
Where to go next
- Getting started
- Schema design, analyzers and queries
- Thread safety and lifetime and deployment
- Migrating from Lucene.NET
- Versioning and upgrades
- API reference
The project is at its 1.0 release candidate: the API is frozen, and changes before 1.0.0 are made only to fix problems that RC feedback turns up. Source, issues and discussions are on GitHub.