AzureAISearchEmbeddingStorageService
Namespace: Wisej.AI.Services
Assembly: Wisej.AI
Represents a service for storing and querying embeddings using Azure AI Search.
- C#
- VB.NET
public class AzureAISearchEmbeddingStorageService : IEmbeddingStorageService
Public Class AzureAISearchEmbeddingStorageService
Inherits IEmbeddingStorageService
This class provides methods to store, retrieve, and query embedded documents in a collection. It utilizes Azure AI Search for vector-based queries and document management.
Constructors
AzureAISearchEmbeddingStorageService(url)
Initializes a new instance of the AzureAISearchEmbeddingStorageService class.
| Name | Type | Description |
|---|---|---|
| url | String | The base URL for the Azure AI Search service. Default is null. |
Properties
ApiKey
String: Gets or sets the API key for authenticating with the Azure AI Search service. (Default: null)
Setting this property will reset the internal HTTP client.
ApiVersion
String: Gets or sets the API version for the Azure AI Search service. (Default: "2024-07-01")
URL
String: Gets or sets the base URL for the Azure AI Search service. (Default: null)
Methods
ExistsAsync(collectionName, documentName)
Checks if a document exists in the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
Returns: Task<Boolean>. A task that represents the asynchronous operation. The task result contains a boolean indicating whether the document exists.
GetApiKey()
Retrieves the API key for the service.
Returns: String. The API key as a string.
QueryAsync(collectionName, query, topN, minSimilarity, filter)
Queries the collection for documents similar to the provided query vector.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top results to return. |
| minSimilarity | Single | The minimum similarity threshold. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for the documents. Default is null. |
Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.
QueryAsync(collectionName, documentName, query, topN, minSimilarity)
Queries a specific document in the collection for similarity to the provided query vector.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top results to return. |
| minSimilarity | Single | The minimum similarity threshold. |
Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains an EmbeddedDocument object.
Throws:
- ArgumentNullException Thrown when the document is null.
RemoveAsync(collectionName, filter)
Removes documents from the collection based on a filter.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for the documents. Default is null. |
Returns: Task. A task that represents the asynchronous operation.
RemoveAsync(collectionName, documentName)
Removes a specific document from the collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
Returns: Task. A task that represents the asynchronous operation.
Throws:
- ArgumentNullException Thrown when the document is null.
RetrieveAsync(collectionName, documentName, includeEmbedding)
Retrieves a specific document from the collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
| includeEmbedding | Boolean | Indicates whether to include the embedding in the retrieval. |
Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains an EmbeddedDocument object.
RetrieveAsync(collectionName, includeEmbedding, filter)
Retrieves documents from the collection based on a filter.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| includeEmbedding | Boolean | Indicates whether to include the embedding in the retrieval. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for the documents. Default is null. |
Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.
StoreAsync(collectionName, document)
Stores a document in the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| document | EmbeddedDocument | The document to store. |
Returns: Task. A task that represents the asynchronous operation.
Throws:
- ArgumentNullException Thrown when the document is null.
Implements
| Name | Description |
|---|---|
| IEmbeddingStorageService | Represents a service for storing and querying embedded documents within specified collections. |