Rig.TUnit.Databases.NoSql.ElasticSearch 0.1.0-beta.2

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

Rig.TUnit.Databases.NoSql.ElasticSearch

Testcontainers-backed Elasticsearch 8.x fixture with IndexRefreshHelper and strongly-typed DslAssert.

What this package is

The Rig.TUnit Elasticsearch provider. ElasticSearchFixture spins Elasticsearch 8.x via Testcontainers and returns an ElasticsearchClient configured for HTTPS + basic auth against the container's self-signed certificate. IndexRefreshHelper.RefreshAsync forces the near-real-time refresh so indexed documents are queryable immediately — required because Elasticsearch's default 1-second refresh interval would otherwise race every test. DslAssert.HitCountAsync<T> provides a fluent hit-count assertion over typed DSL queries.

When to use it

  • Integration tests for full-text search features.
  • Asserting indexed document counts or query-DSL equivalence.
  • Verifying index template / mapping behaviour.
  • Not for: pure-unit search-logic tests — Elasticsearch's query DSL is best tested against a real server.

Prerequisites

  • .NET 10 SDK
  • Docker Desktop / Colima (Elasticsearch image ~1.1 GB)
  • Elastic.Clients.Elasticsearch 8.x (transitive; note Elastic 2.0 / SSPL dual licence).

Quick start

using Rig.TUnit.Databases.NoSql.ElasticSearch.Fixtures;
using Rig.TUnit.Databases.NoSql.ElasticSearch.Helpers;

await using var fx = new ElasticSearchFixture();
await fx.InitializeAsync();

await fx.Client.Indices.CreateAsync("orders");
await IndexRefreshHelper.RefreshAsync(fx.Client, "orders");

Options

Property Type Default Description
Image string "docker.elastic.co/elasticsearch/elasticsearch:8.15.0" Image
StartupTimeoutSeconds int 180 ES boot is slow
Password string "rigtunit" elastic user password
DiscoveryType string "single-node" Dev mode
XpackSecurityEnabled bool true Auth enforced

Fixture + helper APIs

  • Rig.TUnit.Databases.NoSql.ElasticSearch.Fixtures.ElasticSearchFixture
  • Rig.TUnit.Databases.NoSql.ElasticSearch.Options.ElasticSearchFixtureOptions
  • Rig.TUnit.Databases.NoSql.ElasticSearch.Builder.ElasticSearchRigBuilder
  • Rig.TUnit.Databases.NoSql.ElasticSearch.Helpers.IndexRefreshHelper
  • Rig.TUnit.Databases.NoSql.ElasticSearch.Assertions.DslAssert

Per-test isolation

Per-test index naming via IsolationKey: orders_{IsolationKey:short}. DELETE {index} on teardown. Indexes are cheap; full parallelism is safe.

Parallelism + performance

  • First-run pull: ~90 s (~1.1 GB).
  • Warm startup: ~45–60 s.
  • Per-test index create + delete: ~50 ms.
  • Parallelism: 8+ concurrent tests; ES handles index churn well.

Troubleshooting

  • search_phase_execution_exception with zero hits immediately after indexing — you forgot IndexRefreshHelper.RefreshAsync. Default refresh interval is 1 s; tests cannot wait.
  • Certificate validation errors — the fixture disables cert validation on the embedded HttpClient; do not share that handler with production-shaped code.

See docs/troubleshooting.md#elasticsearch.

Provider quirks + edge cases

  • Elasticsearch's match query is analysed by default; use term to hit exact tokens. Tests asserting on non-tokenised content must say so.
  • _id is not searchable by default; use ids query or a mapped keyword field.
  • Index settings are immutable after creation for many fields (shard count, analyser); tests that mutate these must recreate the index.

Benchmarks

See ElasticSearchBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

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 (1)

Showing the top 1 NuGet packages that depend on Rig.TUnit.Databases.NoSql.ElasticSearch:

Package Downloads
Rig.TUnit.All

Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 41 4/27/2026
0.0.0-alpha.0.14 44 4/26/2026