Zymergi.Search.Sqlite 11.4.0-alpha

This is a prerelease version of Zymergi.Search.Sqlite.
dotnet add package Zymergi.Search.Sqlite --version 11.4.0-alpha
                    
NuGet\Install-Package Zymergi.Search.Sqlite -Version 11.4.0-alpha
                    
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="Zymergi.Search.Sqlite" Version="11.4.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zymergi.Search.Sqlite" Version="11.4.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Zymergi.Search.Sqlite" />
                    
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 Zymergi.Search.Sqlite --version 11.4.0-alpha
                    
#r "nuget: Zymergi.Search.Sqlite, 11.4.0-alpha"
                    
#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 Zymergi.Search.Sqlite@11.4.0-alpha
                    
#: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=Zymergi.Search.Sqlite&version=11.4.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Zymergi.Search.Sqlite&version=11.4.0-alpha&prerelease
                    
Install as a Cake Tool

Zymergi.Search.Sqlite

Embedded SQLite adapter for the engine-neutral search contracts in Zymergi.Core (ISearchProvider<T>, ISearchIndexer<T>, IIndexManager). No search server: one database file is the whole engine. Good for small sites, local development, and tests.

Targets .NET 10. Depends on Zymergi.Core, Zymergi.Data, Microsoft.Data.Sqlite, and SQLitePCLRaw.bundle_e_sqlite3. Supports every SearchCapabilities feature: recency, range, stats, and date-histogram facets, highlighting, and exact totals.

Install

dotnet add package Zymergi.Search.Sqlite

Register in Program.cs

{ "SqliteSearch": { "ConnectionString": "Data Source=App_Data/search.db" } }
using Zymergi.Search;
using Zymergi.Search.Sqlite;

builder.Services
    .AddSqliteSearch(builder.Configuration)                       // reads SqliteSearch:ConnectionString
    .AddSqliteSearchIndex<ProductDoc>("products", d => d.Id);     // singleton provider + indexer

var app = builder.Build();

// Create the index once, at startup or in a deploy step.
var indexes = app.Services.GetRequiredService<IIndexManager>();
if (!await indexes.ExistsAsync("products"))
{
    await indexes.CreateAsync("products", ProductDoc.Definition);
}

The document is a plain record you own. Field names in the IndexDefinition must match the JSON property names (System.Text.Json, so Title stays Title):

public sealed record ProductDoc(string Id, string Title, string Brand, double Price, DateTimeOffset Released)
{
    public static readonly IndexDefinition Definition = new(
    [
        new FieldDefinition("Id",       FieldType.Keyword, Filterable: true),
        new FieldDefinition("Title",    FieldType.Text,    Searchable: true),
        new FieldDefinition("Brand",    FieldType.Keyword, Filterable: true, Facetable: true),
        new FieldDefinition("Price",    FieldType.Number,  Filterable: true, Sortable: true),
        new FieldDefinition("Released", FieldType.Date,    Filterable: true, Sortable: true),
    ]);
}

Use it

app.MapGet("/search", async (string? q, string? brand, int page, ISearchProvider<ProductDoc> search, CancellationToken ct) =>
{
    var result = await search.SearchAsync(new SearchRequest
    {
        Query = q,
        Filter = brand is null ? null : new TermFilter("Brand", brand),
        Facets = [new TermsFacetRequest("Brand")],
        Sort = q is null ? [new SortClause("Released", SortDirection.Descending)] : [],
        Offset = Math.Max(page, 0) * 20,
        Limit = 20,
    }, ct);
    return Results.Ok(new { result.TotalCount, Hits = result.Hits.Select(h => h.Document), result.Facets });
});

Indexing from a service:

public sealed class ProductIndexer(ISearchIndexer<ProductDoc> indexer)
{
    public Task UpsertAsync(IEnumerable<ProductDoc> docs, CancellationToken ct) => indexer.IndexAsync(docs, ct);
    public Task RemoveAsync(IEnumerable<string> ids, CancellationToken ct) => indexer.DeleteAsync(ids, ct);
}

Best practices

  • Depend on ISearchProvider<T> and ISearchIndexer<T>, never on the adapter types. You can swap in Zymergi.Search.Elastic or Zymergi.Search.Meili by changing only the registration.
  • Pass the request's CancellationToken.
  • Index in batches (IndexAsync takes many documents and writes them in one transaction). Index from a background job or a queue, not inside the user's request when you can avoid it.
  • Each call opens its own SqliteConnection (pooled by Microsoft.Data.Sqlite). SQLite allows one writer at a time: keep write batches moderate, and run one indexer process per file.
  • Keep the database file on local disk, not a network share.
  • Rate-limit public search endpoints (AddRateLimiter) and cache popular queries with output caching or HybridCache.
  • Check search.Capabilities before you offer a feature that another engine may not support.

Testing

  • Use a temp file per test fixture: Data Source={Path.GetTempPath()}/search-{Guid.NewGuid():n}.db. Call SqliteConnection.ClearAllPools() before you delete the file.
  • Do not use plain Data Source=:memory:. Each operation opens a new connection, and each new in-memory connection is a new, empty database. A named shared-cache memory database (Data Source=name;Mode=Memory;Cache=Shared) works only while some other connection to it stays open.
  • You can build SqliteIndexManager, SqliteSearchIndexer<T>, and SqliteSearchProvider<T> directly from a connection string in tests.

Gotchas

  • Index and field names must be letters, digits, or underscores, and must not start with a digit. They become table and column names.
  • A full-text companion table (FTS5) is created only when the definition has a Searchable field.
  • Recency is honored here but ignored by Meili. An explicit Sort always wins over recency.

Version notes

11.4.0-alpha: no API change in this package. The README sample no longer uses Zymergi.Articles, which is not packed, and no longer suggests :memory:.

Source: bitbucket.org/zymergy/zymergi.saas

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.4.0-alpha 52 11/16/2026
11.3.0-alpha 64 11/12/2026
11.2.0-alpha 61 11/2/2026
11.1.1-alpha 72 10/4/2026
11.1.0-alpha 103 10/1/2026
11.0.6-alpha 88 7/10/2026
11.0.5-alpha 79 7/9/2026
11.0.4-alpha 78 7/6/2026
11.0.3-alpha 82 7/6/2026