Open Search

Description

OpenSearch can be used as the backing implementation for Flex vector similarity search. Your application code should depend on IFlexVectorStore, while the provider implementation handles the OpenSearch client and index operations.

Important concepts

  • IFlexVectorStore is the contract: app code performs upserts and similarity search through the shared interface, not OpenSearch client APIs.

  • Upsert + search: generated handlers typically call UpsertAsync(id, vector, metadata, content), and generated queries call SearchAsync(queryVector, topK, filter, minScore).

  • Custom auth: if you need OpenSearch-specific auth (e.g., AWS SigV4), use the overload that accepts an IOpenSearchClient factory.

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; // IFlexVectorStore

public static class OtherApplicationServicesConfig
{
	public static IServiceCollection AddOtherApplicationServices(
		this IServiceCollection services,
		IConfiguration configuration)
	{
		var section = configuration.GetSection("FlexBase:DataStores:Vector:OpenSearch");

		services.AddFlexOpenSearchVectorStore(options =>
		{
			section.Bind(options);
		});

		// Flex auto-wires generated Queries/Handlers/Plugins that *use* IFlexVectorStore.
		return services;
	}
}

appsettings.json

Configuration is read from FlexBase:DataStores:Vector:OpenSearch.

Examples (template-based)

These examples mirror the generated Query and PostBus handler templates. You do not register these types manually—Flex discovers and wires generated Queries/Handlers/Plugins automatically.

Similarity search (Query)

Upsert a vector record (PostBus handler)

OpenSearch considerations

  • Dimensions must match the embedding model you use.

  • Ensure your OpenSearch index mapping includes a vector field compatible with your chosen similarity algorithm.

  • For advanced auth (AWS SigV4, custom cert handling, etc.), use the AddFlexOpenSearchVectorStore(Func<IServiceProvider, IOpenSearchClient> clientFactory, ...) overload.

Last updated