AzureSearchDocumentStore<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.DocumentStores
Azure AI Search document store backed by the real Azure AI Search REST API.
Inheritance: DocumentStoreBase<T> → AzureSearchDocumentStore<T>
Implements: IDisposable
For Beginners
Azure AI Search is Microsoft’s managed search-and-vector service.
This class is a real client for it - every method here makes an HTTP call to your search
service. Authentication uses the api-key header and every request carries an
api-version query-string parameter.
How It Works
This store talks to an Azure AI Search service over HTTP. It manages a single index with a
vector field and an HNSW vector-search profile, upserts documents via the mergeOrUpload
action, performs vector search with an OData $filter, deletes documents via the
delete action and pages the whole index. The original id and content are stored under
id and content; the full metadata dictionary is stored as a JSON string under
metadata_json (for lossless round-tripping) while each scalar metadata entry is also
flattened to a top-level field so it can be used in $filter expressions.
API deviation: Azure indexes have a fixed schema, so metadata keys used in filters
must exist as filterable fields in the index. This client creates the index with the base fields
(id, content, metadata_json, embedding); flattened metadata fields are
still sent on upload and referenced by $filter, but for production filtering the caller
should ensure those fields are declared in the index (or pre-create the index).
Constructors
| Constructor | Summary |
|---|---|
AzureSearchDocumentStore(string indexName, string endpoint, string apiKey, DistanceMetricType distanceMetric, int vectorDimension, string apiVersion, HttpClient httpClient, HttpMessageHandler handler) |
Initializes a new instance of the AzureSearchDocumentStore class. |
Properties
| Property | Summary |
|---|---|
int DocumentCount { get; } |
Gets the number of documents currently stored in the index. |
int VectorDimension { get; } |
Gets the dimensionality of vectors stored in this index. |
string IndexName { get; } |
Gets the name of the Azure AI Search index this store is bound to. |
Methods
| Method | Summary |
|---|---|
Task ClearAsync(CancellationToken cancellationToken) |
|
void Clear() |
|
void Dispose() |
Releases the HTTP client when this store created it. |