# Vector Store

## Description

Vector store providers register through `IFlexVectorStore`. Your application code stays provider-agnostic while the selected provider handles storage, indexing, and similarity search.

## Infrastructure arrangement

When you add a vector store provider through **Flex Studio**, Flex generates the provider infrastructure and configuration:

1. Provider files under `Infrastructure/Providers/{YourApplication}.DataStoreProviders/Vector/{Provider}/`
2. Default configuration under `Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/DataStores/Vector/{Provider}.json`

Flex auto-wires generated Queries/Handlers/Plugins that use `IFlexVectorStore`—you only register the provider.

## Configuration in DI

Register only the provider vector store you need.

```csharp
// Example: Azure AI Search (options-bound provider)
var section = configuration.GetSection("FlexBase:DataStores:Vector:AzureAISearch");
services.AddFlexAzureAISearchVectorStore(options => section.Bind(options));

// Example: SQL Server / pgvector (parameter-based providers)
// var section = configuration.GetSection("FlexBase:DataStores:Vector:SqlServer");
// services.AddFlexSqlServerVectorStore(
// 	connectionString: section.GetValue<string>("ConnectionString")!,
// 	tableName: section.GetValue<string>("TableName")!,
// 	dimensions: section.GetValue<int?>("Dimensions") ?? 1536);
```

## appsettings.json

Vector store configuration is read from `FlexBase:DataStores:Vector:<Provider>`.

```json
{
  "FlexBase": {
    "DataStores": {
      "Vector": {
        "AzureAISearch": {
          "Endpoint": "https://your-search-service.search.windows.net",
          "ApiKey": "<store-in-secrets>",
          "IndexName": "your-index-name",
          "Dimensions": 1536
        }
      }
    }
  }
}
```

## Sample usage ({YourApplication})

```csharp
public class KnowledgeIndex
{
	private readonly IFlexVectorStore _vectorStore;

	public KnowledgeIndex(IFlexVectorStore vectorStore)
		=> _vectorStore = vectorStore;

	public Task UpsertAsync(string id, float[] embedding, object? metadata, string content)
		=> _vectorStore.UpsertAsync(id, embedding, metadata, content);
}
```

## Provider pages

* SQL Server: `vector-store/sql-server-vector.md`
* Azure AI Search: `vector-store/azure-ai-search.md`
* pgvector (PostgreSQL): `vector-store/pg-vector-postgres.md`
* OpenSearch: `vector-store/open-search.md`

## Provider considerations

* `Dimensions` must match the embedding model you use.
* Keep secrets (API keys/connection strings) out of source control.
* For hybrid retrieval, combine Vector Store (semantic) + Full-Text Search (keyword/filtering).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flexbase.in/data-and-providers/data-stores/vector-store.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
