MooFile 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MooFile --version 1.0.0
                    
NuGet\Install-Package MooFile -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MooFile" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MooFile" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MooFile" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MooFile --version 1.0.0
                    
#r "nuget: MooFile, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MooFile@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MooFile&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MooFile&version=1.0.0
                    
Install as a Cake Tool

MooFile

Lightweight embedded document store — MongoDB-style queries, vector search and BM25 text search over a single file. No server, no infrastructure.

dotnet add package MooFile

Native libraries for linux (x64, arm64), macOS (Intel, Apple Silicon) and Windows (x64) ship inside the package. The SDK copies the right one to your output directory automatically — there is no build step and nothing to install.

Usage

using Moofile;

using var db = Collection.Open("data.bson", new Config {
    Indexes = new[] { "email" },
    VectorIndexes = new Dictionary<string, int> { ["embedding"] = 384 },
    TextIndexes = new[] { "content" },
});

db.Insert(Document.Of("name", "Alice", "email", "alice@example.com", "age", 30));
db.InsertMany(new[] {
    Document.Of("name", "Bob", "age", 25),
    Document.Of("name", "Carol", "age", 35),
});

// Filters
db.FindOne(Document.Of("email", "alice@example.com"));
db.Find(Document.Of("age", Document.Of("$gte", 30)));

// Sorting, paging, aggregation
db.Find(null, FindOptions.Create().Sort("age", desc: true).Limit(10));
db.Find(null, FindOptions.Create().Group("region").Count().Sum("amount"));

// Search
db.VectorSearch("embedding", queryVector, 5);      // → List<SearchResult>
db.TextSearch("content", "machine learning", 5);

// Atomic writes — rolls back if the delegate throws
db.Batch(() => {
    db.Insert(Document.Of("_id", "a", "amount", 100));
    db.Insert(Document.Of("_id", "b", "amount", -50));
});

Things worth knowing

Documents hold plain CLR values — string, long, double, bool, List<object?>, nested Document — not JsonElement. So doc["age"] compares and casts the way you would expect.

UpdateOne and ReplaceOne throw MooFileException when nothing matches. This mirrors the Rust and Python APIs, which raise DocumentNotFound. UpdateMany, DeleteOne and DeleteMany do not — they return 0/false. Call Exists first when a miss is expected.

_id is always a string, assigned on insert if you do not supply one.

Query stages apply in the order filter → group/agg → sort → skip → limit. An unrecognised aggregation name is an error rather than being ignored. Aggregation output fields are named count, sum_<field>, mean_<field>, and so on.

Stats().GetDouble("dead_ratio") is what to threshold on before calling Compact(). Note that one delete produces two dead records — the superseded original plus a tombstone.

Thread safety. A Collection may be shared between threads. Dispose it when done, or use using.

With an AutoEmbed source field configured, documents are embedded on insert using a local GGUF model, and query text is embedded for you:

using var db = Collection.Open("semantic.bson", new Config {
    VectorIndexes = new Dictionary<string, int> { ["embedding"] = 1024 },
    AutoEmbed = new Dictionary<string, AutoEmbedConfig> {
        ["content"] = new AutoEmbedConfig {
            Model = "hf:jsonMartin/voyage-4-nano-gguf:voyage-4-nano-q8_0.gguf",
            Target = "embedding",
            Dims = 1024,
            Precision = "int8",
        },
    },
});

db.Insert(Document.Of("content", "Machine learning is fascinating"));
db.Semantic("content", "deep learning", 5);

The model downloads on first use and is cached.

Using a different library build

Set MOOFILE_LIB to a libmoofile path to override the bundled binary:

MOOFILE_LIB=/path/to/libmoofile.so dotnet run

MIT licensed.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.5 92 9/22/2026
1.2.4 86 9/14/2026
1.2.3 99 9/14/2026
1.2.2 128 8/18/2026
1.2.1 109 8/16/2026
1.1.1 114 8/15/2026
1.1.0 107 8/15/2026
1.0.4 114 8/8/2026
1.0.2 112 8/7/2026
1.0.1 106 8/7/2026
1.0.0 116 8/7/2026