Postgre Sql Full Text Search
Description
PostgreSQL full-text search can be used as the backing implementation for Flex search operations. Your application code should depend on IFlexSearchStore, while Flex provides the provider bridge and wiring.
Important concepts
IFlexSearchStoreis the contract: app code performs searches and indexing through the shared interface.Search configuration: PostgreSQL uses a text search configuration (for example
english) to control tokenization and stemming.Provider bridge: the PostgreSQL implementation is exposed via an
IFlexSearchStoreBridgeinternally, but most consumers only needIFlexSearchStore.
Configuration in DI
Add the provider in your DI composition root (commonly in EndPoints/...CommonConfigs/OtherApplicationServicesConfig.cs or wherever you centralize registrations).
// using Sumeru.Flex; // IFlexSearchStore
public static class OtherApplicationServicesConfig
{
public static IServiceCollection AddOtherApplicationServices(
this IServiceCollection services,
IConfiguration configuration)
{
// Registers PostgreSQL full-text search as the IFlexSearchStore bridge.
// Flex auto-wires generated Queries/Plugins that *use* IFlexSearchStore.
services.AddFlexPostgreSqlSearchStore(configuration);
return services;
}
}appsettings.json
Configuration is read from FlexBase:DataStores:Search:PostgreSql.
Examples (template-based)
These examples mirror the generated Query and PostBus plugin templates. You do not register these types manually—Flex discovers and wires generated Queries/Handlers/Plugins automatically.
Search a paged list (Query)
PostgreSQL considerations
Ensure your database/table setup supports full-text indexes for your data shape.
SearchConfigurationshould match the language/analyzer behavior you expect (for examplesimplevsenglish).
Last updated