LexiSharp.Postgres
0.10.0
dotnet add package LexiSharp.Postgres --version 0.10.0
NuGet\Install-Package LexiSharp.Postgres -Version 0.10.0
<PackageReference Include="LexiSharp.Postgres" Version="0.10.0" />
<PackageVersion Include="LexiSharp.Postgres" Version="0.10.0" />
<PackageReference Include="LexiSharp.Postgres" />
paket add LexiSharp.Postgres --version 0.10.0
#r "nuget: LexiSharp.Postgres, 0.10.0"
#:package LexiSharp.Postgres@0.10.0
#addin nuget:?package=LexiSharp.Postgres&version=0.10.0
#tool nuget:?package=LexiSharp.Postgres&version=0.10.0
LexiSharp
Search and retrieval for .NET โ BM25, rank fusion and reranking in composable pipelines.
In-memory inverted index, four ranking strategies and their BM25 variants, rank fusion, reranking, IR metrics and end-to-end search traces. The core references no NuGet package at all (BCL only). PostgreSQL, ASP.NET Core and MessagePack are separate, optional packages, and your models stay in your application behind a seam you implement.
- Nothing to host. No vector database, no embedding API, no native library.
- Explainable ranking. Every stage writes a
SearchTrace(score in/out);Explainbreaks a scorer down to its per-term contributions. - Composition, not configuration. Index, scorer and engine are separate interfaces; hybrid
retrieval and reranking are decorators over the same
ITextSearchEngine. - Measured, not asserted. The plain BM25 scorer is checked against published BEIR figures and re-checked by a workflow on every relevant push and weekly.
๐ Documentation โ โ guide, reference, and every measurement with the command that reproduces it.
Quick start
dotnet add package LexiSharp
using LexiSharp.Core;
using LexiSharp.Indexing;
using LexiSharp.Ranking;
ITextSearchEngine engine = new RankedTextSearchEngine(
new InMemoryTextIndex(), new Bm25Scorer());
engine.Index(new[]
{
new SearchDocument("1", "The search engine uses BM25 to rank the results"),
new SearchDocument("2", "TF-IDF is a classic method of textual search"),
new SearchDocument("3", "Italian cuisine is renowned in Rome"),
});
foreach (var r in engine.Search("textual search"))
Console.WriteLine($"{r.DocumentId} - {r.Score:0.###}: {r.Document.Text}");
Hybrid retrieval and reranking are stages wrapping each other โ see pipelines and getting started.
Does it work?
nDCG@10 on three public BEIR corpora, with analysis, BM25 parameters and metric convention aligned to the published figures:
| Corpus | LexiSharp | Published |
|---|---|---|
| NFCorpus | 0.3218 | 0.3218 |
| SciFact | 0.6789 | 0.6789 |
| ArguAna | 0.4005 | 0.3970 |
Point estimates; the harness also reports paired-bootstrap 95 % CIs. Under the library's own
default analysis and parameters the same scorer reads 0.308 / 0.662 / 0.320 โ the difference is
configuration, not ranking. Corpora are md5-verified; numbers are pinned and re-checked by the
Pinned reference workflow.
Full tables, CIs, backends and reproducibility: evaluation โ.
See it running
dotnet run --project samples/LexiSharp.Demo # โ http://localhost:5000
Five retrieval strategies over one corpus, compared live โ BM25, corpus-derived semantic expansion, dense hashing embeddings, RRF fusion and a term-overlap rerank โ with per-lane latency, highlighting and a click-through "why did this rank here?" panel. No model, no external service.

--corpus nfcorpus|scifact|arguana runs the same lanes over a BEIR corpus. Details:
getting started โ.
Packages
| Package | What it adds |
|---|---|
LexiSharp |
Core: index, scorers, fusion, reranking, metrics, traces โ no dependencies |
LexiSharp.Postgres |
tsvector ยท pgvector ยท sparsevec ยท pg_trgm ยท pg_search (Tantivy) BM25 |
LexiSharp.Onnx |
Local ONNX embeddings and cross-encoder reranking (no model shipped) |
LexiSharp.MessagePack |
Binary persistence for the in-memory index |
LexiSharp.AspNetCore |
GET /search minimal-API endpoint over LexiSharpIndex<T> |
LexiSharp.Cli |
dotnet tool: search a directory, build a store, benchmark a config |
Text analysis (lexical similarity, keyword extraction, Naive Bayes, decision tree, ensemble, linear classifier): text analysis โ.
Limits (short version)
- net10.0, 0.9.0: the public API may still change between minor versions; pin a version
and read the changelog. 0.9.0 breaks binary compatibility for
ITextSearchEngineimplementations, write-capable engine constructors andSearchResult. - ArguAna reads 0.4005 against 0.3970 published (0.0035 short; cause not established). An earlier ArguAna figure was withdrawn and is not reproducible by any code path.
- Not every engine/scorer/reranker/merger combination is tested; treat unusual pairings as supported but unproven until tested on your data.
- SQL backends are measured on ranking for the engines that rank on their own; sparse and fuzzy engines are covered by integration tests only.
Full list with measurements: scope and limits โ.
Development
dotnet build LexiSharp.slnx
dotnet test tests/LexiSharp.Tests
dotnet run --project bench/LexiSharp.Eval -c Release -- --verify-reference # quality gate
The retrieval quality gate replays every pinned configuration on the three BEIR corpora and exits non-zero on drift (downloads corpora on first run). Benchmarks and the behavioural gate: reference โ, benchmarks โ.
License
MIT โ see LICENSE. The ParadeDB pg_search extension used by the BM25 backend is
licensed separately, under AGPL-3.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.