Search Providers
Orleans.Search uses a pluggable provider architecture that allows you to use different database backends for your search index.
How Providers Work
A search provider is responsible for:
- Storing grain state in a searchable database
- Translating LINQ queries to database-specific queries
- Returning grain IDs that match search predicates
- Full-text search (optional, database-specific)
Architecture
IClusterClient.Search<TGrain>()
|
v
OrleansQueryProvider (LINQ translation)
|
v
ISearchProvider<TGrain, TState>
|
v
SearchProviderBase<TGrain, TState, TEntity>
|
v
Database-Specific Provider (PostgreSQL, etc.)
|
v
Database (PostgreSQL, SQL Server, etc.)Available Providers
| Provider | Package | Status |
|---|---|---|
| PostgreSQL | TGHarker.Orleans.Search.PostgreSql | Stable |
Choosing a Provider
PostgreSQL
Best for:
- Production workloads
- Full-text search with ranking
- Complex queries with multiple filters
- Large datasets requiring indexes
builder.Services.AddOrleansSearch()
.UsePostgreSql(connectionString);Custom Providers
You can create custom providers for other databases. See Creating Custom Providers for details.
Provider Registration
All providers follow the same registration pattern:
var builder = WebApplication.CreateBuilder(args);
// Configure Orleans
builder.UseOrleans(siloBuilder =>
{
siloBuilder.UseLocalhostClustering();
siloBuilder.AddMemoryGrainStorage("InnerStorage");
siloBuilder.AddSearchableGrainStorage("InnerStorage");
});
// Add Orleans.Search with your chosen provider
builder.Services.AddOrleansSearch()
.UsePostgreSql(connectionString); // Or your custom providerSource-Generated Components
When you mark a grain state with [Searchable], the source generator creates:
| Component | Purpose |
|---|---|
| Entity Class | EF Core entity with queryable properties |
| Search Provider | Maps state to entity and executes queries |
| Entity Configuration | Database indexes and constraints |
These generated components work with any provider that uses Entity Framework Core.
Next Steps
- PostgreSQL Provider - Configure PostgreSQL
- Creating Custom Providers - Build your own provider