r/dotnet • u/jordansrowles • 3h ago
Promotion LeanCorpus 4 - Native AOT full-text search
It's been a few months since I last posted about LeanCorpus (formerly LeanLucene), a low-allocation, Native AOT-compatible alternative to Lucene.NET that I've been building.
I've just released LeanCorpus 4.0 and Rowles.Text 2.0, and moved over to .NET 11 GA whilst retaining .NET 10 support.
Quite a lot has changed since my last post:
- Concurrent indexing using what I'm calling PDWPT (Pooled Document Writer Per Thread), with background flushing and improved memory management.
- Geo and XY spatial search using multidimensional Packed BKD trees, including polygons, geometry collections and spatial aggregations. (Geospatial was this releases theme)
- A new pooled postings store, streamed FST construction and further allocation reductions.
- A substantially reworked query parser and a lot of improvements to query correctness and scoring.
- Better crash recovery, commit durability and index format management.
- A public index inspection API and an interactive CLI workbench.
Benchmarks are still good (currently building the benchmark records site). Indexing takes half the time of Lucene.NET. Nearly all functionality has lower allocation, text analysis pipelines are zero-allocation.
Rowles.Text has had quite a bit of love too. Following some feedback about the German stemmer, I ended up replacing nine of the language stemmers with generated implementations of the official Snowball 3.2.0 algorithms, using my own allocation-free runtime.
They now match the reference word lists exactly, with zero differences across a further 2.1 million fuzz-generated inputs, missing none. They're actually ever so slightly slower than my previous implementations, but those were also wrong on thousands of words, so I'll take that trade-off.
There's also been work on Chinese, Japanese, Korean, Thai and Slovak analysis, Unicode handling, tokenisation and concurrent analysis. Analysers are now versioned too, so the engine won't silently let you mix incompatible analysis pipelines in an index.
I've also spent a probably disproportionate amount of time replacing my growing collection of Bash and PowerShell scripts with a managed .NET DevOps CLI for building, testing, benchmarking and generally managing the project.
I've gone a bit nuts with the testing to be honest. Unit, integration, deterministic state machines, property-based tests, fault injection, crash recovery and Native AOT smoke tests. Quite a lot of effort goes into checking what happens when things go wrong, especially around file lifetimes, concurrent access and interrupted commits. If Stryker 5 passes its next spike, then mutation testing will also be thrown in.
Something I didn't expect
Something quite interesting happened a few days ago. I tried running the unmodified core engine inside Blazor WASM, not really expecting much to come of it. It ended up successfully indexing, committing, reopening and searching indexes entirely within Chromium and Firefox. So proper browser support is now on the list for 5.0.
Other things I'm looking at for 5.0 include alternative postings representations, further indexing improvements, an Orchard Core-based server, a browser-based text analysis playground and some experimental work around .NET garbage collection.
Still entirely CPU-based, Native AOT-compatible and the core still maintains 0 dependencies.
As always, feedback and criticism are always welcome. I'm particularly interested in hearing from native speakers of the languages supported by Rowles.Text, as there's only so much I can personally verify when it comes to language analysis.


