SOFTURE.Typesense 2.0.0

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

SOFTURE.Typesense

Typesense wrapper for .NET with support for strongly typed models, filters, and queries.

Installation

dotnet add package SOFTURE.Typesense
dotnet add package SOFTURE.Typesense.Abstractions

Quick Start

1. Define Document Model

public sealed class ProductDocument : DocumentBase
{
    public ProductDocument() : base(collection: "products") { }

    public override required string Id { get; set; }

    [JsonPropertyName("name")]
    public string? Name { get; set; }

    [JsonPropertyName("price")]
    public decimal Price { get; set; }

    [JsonPropertyName("is_active")]
    public bool IsActive { get; set; }

    [JsonPropertyName("tags")]
    public string[]? Tags { get; set; }
}

2. Define Query Model

public sealed class ProductQuery : QueryBase
{
    public ProductQuery() : base(collection: "products") { }

    [JsonPropertyName("name")]
    public string? Name { get; set; }
}

3. Define Filters with Operators

public sealed class ProductFilters : FilterBase
{
    public ProductFilters() : base(collection: "products") { }

    [JsonPropertyName("is_active")]
    public bool? IsActive { get; set; }

    [FilterOperator(FilterOperator.LessThan)]
    [JsonPropertyName("price")]
    public decimal? Price { get; set; }

    [FilterOperator(FilterOperator.GreaterThan)]
    [JsonPropertyName("quantity")]
    public int? Quantity { get; set; }

    [FilterOperator(FilterOperator.Range)]
    [JsonPropertyName("created_at")]
    public (long From, long To)? CreatedAt { get; set; }

    [FilterOperator(FilterOperator.NotEquals)]
    [JsonPropertyName("excluded_ids")]
    public string[]? ExcludedIds { get; set; }

    [JsonPropertyName("tags")]
    public string[]? Tags { get; set; }
}

4. Define Sorting

public sealed class ProductSort : SortBase
{
    public ProductSort() : base(collection: "products") { }

    public ProductSort WithName(SortDirection direction)
    {
        Add("name", direction);
        return this;
    }

    public ProductSort WithPrice(SortDirection direction)
    {
        Add("price", direction);
        return this;
    }
}

5. Configure Collection

public sealed class ProductConfig : ICollectionConfiguration
{
    public ProductConfig()
    {
        Configurations.ConfigureCollection<ProductDocument, ProductQuery, ProductFilters>(
            collectionName: "products",
            fields:
            [
                new Field("name", FieldType.String, facet: false, optional: false, index: true, sort: true),
                new Field("price", FieldType.Float, facet: false, optional: false, index: true, sort: true),
                new Field("is_active", FieldType.Bool, facet: true),
                new Field("tags", FieldType.StringArray, facet: true, optional: true)
            ],
            defaultSortingField: "name"
        );
    }

    public List<CollectionConfiguration> Configurations { get; } = [];
}

6. Usage

await documentClient.ImportDocuments(products, batchSize: 100);

var query = new ProductQuery { Name = "iPhone" };

var filters = new ProductFilters
{
    IsActive = true,
    Price = 1000,
    Tags = ["electronics", "smartphones"]
};

var sort = new ProductSort()
    .WithPrice(SortDirection.Asc)
    .WithName(SortDirection.Desc);

var result = await documentClient.Search<ProductDocument, ProductQuery, ProductFilters, ProductSort>(
    query: query,
    filters: filters,
    sortBy: sort
);

Available Filter Operators

  • Default - Equals (=)
  • FilterOperator.NotEquals - Not equals (:!=)
  • FilterOperator.LessThan - Less than (:<)
  • FilterOperator.LessThanOrEquals - Less than or equals (:<=)
  • FilterOperator.GreaterThan - Greater than (:>)
  • FilterOperator.GreaterThanOrEquals - Greater than or equals (:>=)
  • FilterOperator.Range - Range (:[]) - requires tuple (From, To)

Field Configuration Parameters

  • facet (default: false) - Fields with true can be filtered and grouped
  • index (default: true) - Set to false for fields that should not be searchable
  • sort (default: false) - Set to true for fields that can be sorted
  • optional (default: false) - Whether the field is optional

Supported Frameworks

Target Typesense client CSharpFunctionalExtensions
net6.0, net8.0 7.36.0 2.42.5
net10.0 9.2.0 3.7.0

On net8.0 and net10.0 the document Id is a required member: declare it as public override required string Id { get; set; }, and mark a constructor that sets it with [SetsRequiredMembers].

The integration tests run against Typesense servers 0.25.1, 28.0 and 30.2. FilterOperator.NotIn needs a server 28.0 or newer; older servers return no hits for it.

Testing

cd TYPESENSE
dotnet test

The integration tests are skipped unless a Typesense server is configured:

docker run -d -p 8108:8108 -e TYPESENSE_DATA_DIR=/tmp -e TYPESENSE_API_KEY=xyz typesense/typesense:28.0
TYPESENSE_TEST_HOST=localhost TYPESENSE_TEST_PORT=8108 TYPESENSE_TEST_API_KEY=xyz dotnet test

Releasing

The single workflow release.yml releases one package per run to nuget.org and creates a GitHub Release with the .nupkg attached.

Short name Package
typesense SOFTURE.Typesense
typesense-abstractions SOFTURE.Typesense.Abstractions

A release starts from a tag <package>@<version> (e.g. typesense@0.2.0) created by hand; the workflow never creates tags. In GitHub: Releases → Draft a new release → Choose a tag → type typesense@0.2.0 → Create new tag on publish, target master → Publish release. Pushing the tag from a terminal works the same way. SOFTURE.Typesense depends on SOFTURE.Typesense.Abstractions of the same version, so release both with one version.

Before publishing, the workflow checks that the commit is on master, builds for net6.0, net8.0 and net10.0, runs the unit tests, runs the integration tests against Typesense 0.25.1, 28.0 and 30.2, blocks on known vulnerabilities on net10.0 (older targets only warn) and checks the package contents. Run workflow on a branch is a dry run.

Publishing goes through nuget.org trusted publishing: the policy (Package Owner SOFTURE, Repository SOFTURE/TYPESENSE, Workflow File release.yml) and the organization secret NUGET_USER (the nuget.org profile name of the policy owner). Keep the workflow file name.

License

See LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 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
2.0.0 59 11/12/2026
0.2.0 50 11/12/2026
0.1.2 1,276 12/10/2025
0.1.1 351 11/10/2025
0.1.0 310 11/10/2025
0.0.15 265 11/6/2025
0.0.14 246 11/5/2025
0.0.13 253 11/5/2025
0.0.12 728 9/7/2024
0.0.11 230 9/7/2024
0.0.10 226 9/3/2024
0.0.9 220 9/3/2024
0.0.8 221 9/2/2024
0.0.7 222 9/2/2024
0.0.6 237 8/20/2024
0.0.5 222 8/20/2024
0.0.4 269 8/15/2024
0.0.3 252 8/12/2024
0.0.2 228 8/12/2024
0.0.1 217 8/12/2024