18
18
namespace Microsoft . SemanticKernel . Connectors . AzureAISearch ;
19
19
20
20
/// <summary>
21
- /// Service for storing and retrieving records, that uses Azure AI Search as the underlying storage.
21
+ /// Service for storing and retrieving vector records, that uses Azure AI Search as the underlying storage.
22
22
/// </summary>
23
23
/// <typeparam name="TRecord">The data model to use for adding, updating and retrieving data from storage.</typeparam>
24
24
public sealed class AzureAISearchVectorRecordStore < TRecord > : IVectorRecordStore < string , TRecord >
@@ -140,9 +140,9 @@ public Task DeleteAsync(string key, DeleteRecordOptions? options = default, Canc
140
140
// Remove record.
141
141
var searchClient = this . GetSearchClient ( collectionName ) ;
142
142
return RunOperationAsync (
143
- ( ) => searchClient . DeleteDocumentsAsync ( this . _keyPropertyName , [ key ] , new IndexDocumentsOptions ( ) , cancellationToken ) ,
144
143
collectionName ,
145
- "DeleteDocuments" ) ;
144
+ "DeleteDocuments" ,
145
+ ( ) => searchClient . DeleteDocumentsAsync ( this . _keyPropertyName , [ key ] , new IndexDocumentsOptions ( ) , cancellationToken ) ) ;
146
146
}
147
147
148
148
/// <inheritdoc />
@@ -156,9 +156,9 @@ public Task DeleteBatchAsync(IEnumerable<string> keys, DeleteRecordOptions? opti
156
156
// Remove records.
157
157
var searchClient = this . GetSearchClient ( collectionName ) ;
158
158
return RunOperationAsync (
159
- ( ) => searchClient . DeleteDocumentsAsync ( this . _keyPropertyName , keys , new IndexDocumentsOptions ( ) , cancellationToken ) ,
160
159
collectionName ,
161
- "DeleteDocuments" ) ;
160
+ "DeleteDocuments" ,
161
+ ( ) => searchClient . DeleteDocumentsAsync ( this . _keyPropertyName , keys , new IndexDocumentsOptions ( ) , cancellationToken ) ) ;
162
162
}
163
163
164
164
/// <inheritdoc />
@@ -214,21 +214,21 @@ private async Task<TRecord> GetDocumentAndMapToDataModelAsync(
214
214
if ( this . _options . MapperType == AzureAISearchRecordMapperType . JsonObjectCustomMapper )
215
215
{
216
216
var jsonObject = await RunOperationAsync (
217
- ( ) => searchClient . GetDocumentAsync < JsonObject > ( key , innerOptions , cancellationToken ) ,
218
217
collectionName ,
219
- "GetDocument" ) . ConfigureAwait ( false ) ;
218
+ "GetDocument" ,
219
+ ( ) => searchClient . GetDocumentAsync < JsonObject > ( key , innerOptions , cancellationToken ) ) . ConfigureAwait ( false ) ;
220
220
221
221
return RunModelConversion (
222
- ( ) => this . _options . JsonObjectCustomMapper ! . MapFromStorageToDataModel ( jsonObject ) ,
223
222
collectionName ,
224
- "GetDocument" ) ;
223
+ "GetDocument" ,
224
+ ( ) => this . _options . JsonObjectCustomMapper ! . MapFromStorageToDataModel ( jsonObject ) ) ;
225
225
}
226
226
227
227
// Use the built in Azure AI Search mapper.
228
228
return await RunOperationAsync (
229
- ( ) => searchClient . GetDocumentAsync < TRecord > ( key , innerOptions , cancellationToken ) ,
230
229
collectionName ,
231
- "GetDocument" ) . ConfigureAwait ( false ) ;
230
+ "GetDocument" ,
231
+ ( ) => searchClient . GetDocumentAsync < TRecord > ( key , innerOptions , cancellationToken ) ) . ConfigureAwait ( false ) ;
232
232
}
233
233
234
234
/// <summary>
@@ -251,21 +251,21 @@ private Task<Response<IndexDocumentsResult>> MapToStorageModelAndUploadDocumentA
251
251
if ( this . _options . MapperType == AzureAISearchRecordMapperType . JsonObjectCustomMapper )
252
252
{
253
253
var jsonObjects = RunModelConversion (
254
- ( ) => records . Select ( this . _options . JsonObjectCustomMapper ! . MapFromDataToStorageModel ) ,
255
254
collectionName ,
256
- "UploadDocuments" ) ;
255
+ "UploadDocuments" ,
256
+ ( ) => records . Select ( this . _options . JsonObjectCustomMapper ! . MapFromDataToStorageModel ) ) ;
257
257
258
258
return RunOperationAsync (
259
- ( ) => searchClient . UploadDocumentsAsync < JsonObject > ( jsonObjects , innerOptions , cancellationToken ) ,
260
259
collectionName ,
261
- "UploadDocuments" ) ;
260
+ "UploadDocuments" ,
261
+ ( ) => searchClient . UploadDocumentsAsync < JsonObject > ( jsonObjects , innerOptions , cancellationToken ) ) ;
262
262
}
263
263
264
264
// Use the built in Azure AI Search mapper.
265
265
return RunOperationAsync (
266
- ( ) => searchClient . UploadDocumentsAsync < TRecord > ( records , innerOptions , cancellationToken ) ,
267
266
collectionName ,
268
- "UploadDocuments" ) ;
267
+ "UploadDocuments" ,
268
+ ( ) => searchClient . UploadDocumentsAsync < TRecord > ( records , innerOptions , cancellationToken ) ) ;
269
269
}
270
270
271
271
/// <summary>
@@ -322,14 +322,14 @@ private GetDocumentOptions ConvertGetDocumentOptions(GetRecordOptions? options)
322
322
}
323
323
324
324
/// <summary>
325
- /// Run the given operation and wrap any <see cref="RequestFailedException"/> with <see cref="HttpOperationException "/>."/>
325
+ /// Run the given operation and wrap any <see cref="RequestFailedException"/> with <see cref="VectorStoreOperationException "/>."/>
326
326
/// </summary>
327
327
/// <typeparam name="T">The response type of the operation.</typeparam>
328
- /// <param name="operation">The operation to run.</param>
329
328
/// <param name="collectionName">The name of the collection the operation is being run on.</param>
330
329
/// <param name="operationName">The type of database operation being run.</param>
330
+ /// <param name="operation">The operation to run.</param>
331
331
/// <returns>The result of the operation.</returns>
332
- private static async Task < T > RunOperationAsync < T > ( Func < Task < T > > operation , string collectionName , string operationName )
332
+ private static async Task < T > RunOperationAsync < T > ( string collectionName , string operationName , Func < Task < T > > operation )
333
333
{
334
334
try
335
335
{
@@ -365,11 +365,11 @@ private static async Task<T> RunOperationAsync<T>(Func<Task<T>> operation, strin
365
365
/// Run the given model conversion and wrap any exceptions with <see cref="VectorStoreRecordMappingException"/>.
366
366
/// </summary>
367
367
/// <typeparam name="T">The response type of the operation.</typeparam>
368
- /// <param name="operation">The operation to run.</param>
369
368
/// <param name="collectionName">The name of the collection the operation is being run on.</param>
370
369
/// <param name="operationName">The type of database operation being run.</param>
370
+ /// <param name="operation">The operation to run.</param>
371
371
/// <returns>The result of the operation.</returns>
372
- private static T RunModelConversion < T > ( Func < T > operation , string collectionName , string operationName )
372
+ private static T RunModelConversion < T > ( string collectionName , string operationName , Func < T > operation )
373
373
{
374
374
try
375
375
{
0 commit comments