@@ -445,18 +445,18 @@ public async Task<ReplaceAllObjectsResponse> ReplaceAllObjectsAsync<T>(string in
445
445
446
446
var copyResponse = await OperationIndexAsync ( indexName ,
447
447
new OperationIndexParams ( OperationType . Copy , tmpIndexName )
448
- { Scope = [ ScopeType . Rules , ScopeType . Settings , ScopeType . Synonyms ] } , options , cancellationToken )
448
+ { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
449
449
. ConfigureAwait ( false ) ;
450
450
451
- var batchResponse = await ChunkedBatchAsync ( tmpIndexName , objects , Action . AddObject , batchSize ,
451
+ var batchResponse = await ChunkedBatchAsync ( tmpIndexName , objects , Action . AddObject , true , batchSize ,
452
452
options , cancellationToken ) . ConfigureAwait ( false ) ;
453
453
454
454
await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
455
455
. ConfigureAwait ( false ) ;
456
456
457
457
copyResponse = await OperationIndexAsync ( indexName ,
458
458
new OperationIndexParams ( OperationType . Copy , tmpIndexName )
459
- { Scope = [ ScopeType . Rules , ScopeType . Settings , ScopeType . Synonyms ] } , options , cancellationToken )
459
+ { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
460
460
. ConfigureAwait ( false ) ;
461
461
await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
462
462
. ConfigureAwait ( false ) ;
@@ -487,9 +487,9 @@ await WaitForTaskAsync(tmpIndexName, moveResponse.TaskID, requestOptions: option
487
487
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
488
488
/// <typeparam name="T"></typeparam>
489
489
public List < BatchResponse > ChunkedBatch < T > ( string indexName , IEnumerable < T > objects , Action action = Action . AddObject ,
490
- int batchSize = 1000 , RequestOptions options = null , CancellationToken cancellationToken = default )
490
+ bool waitForTasks = false , int batchSize = 1000 , RequestOptions options = null , CancellationToken cancellationToken = default )
491
491
where T : class =>
492
- AsyncHelper . RunSync ( ( ) => ChunkedBatchAsync ( indexName , objects , action , batchSize , options , cancellationToken ) ) ;
492
+ AsyncHelper . RunSync ( ( ) => ChunkedBatchAsync ( indexName , objects , action , waitForTasks , batchSize , options , cancellationToken ) ) ;
493
493
494
494
/// <summary>
495
495
/// Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
@@ -502,7 +502,7 @@ public List<BatchResponse> ChunkedBatch<T>(string indexName, IEnumerable<T> obje
502
502
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
503
503
/// <typeparam name="T"></typeparam>
504
504
public async Task < List < BatchResponse > > ChunkedBatchAsync < T > ( string indexName , IEnumerable < T > objects ,
505
- Action action = Action . AddObject , int batchSize = 1000 , RequestOptions options = null ,
505
+ Action action = Action . AddObject , bool waitForTasks = false , int batchSize = 1000 , RequestOptions options = null ,
506
506
CancellationToken cancellationToken = default ) where T : class
507
507
{
508
508
var batchCount = ( int ) Math . Ceiling ( ( double ) objects . Count ( ) / batchSize ) ;
@@ -518,10 +518,13 @@ public async Task<List<BatchResponse>> ChunkedBatchAsync<T>(string indexName, IE
518
518
responses . Add ( batchResponse ) ;
519
519
}
520
520
521
- foreach ( var batch in responses )
521
+ if ( waitForTasks )
522
522
{
523
- await WaitForTaskAsync ( indexName , batch . TaskID , requestOptions : options , ct : cancellationToken )
524
- . ConfigureAwait ( false ) ;
523
+ foreach ( var batch in responses )
524
+ {
525
+ await WaitForTaskAsync ( indexName , batch . TaskID , requestOptions : options , ct : cancellationToken )
526
+ . ConfigureAwait ( false ) ;
527
+ }
525
528
}
526
529
527
530
return responses ;
@@ -544,7 +547,7 @@ public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEn
544
547
RequestOptions options = null ,
545
548
CancellationToken cancellationToken = default ) where T : class
546
549
{
547
- return await ChunkedBatchAsync ( indexName , objects , Action . AddObject , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
550
+ return await ChunkedBatchAsync ( indexName , objects , Action . AddObject , false , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
548
551
}
549
552
550
553
/// <summary>
@@ -554,11 +557,11 @@ public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEn
554
557
/// <param name="objectIDs">The list of `objectIDs` to remove from the given Algolia `indexName`.</param>
555
558
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
556
559
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
557
- public async Task < List < BatchResponse > > DeleteObjects ( string indexName , IEnumerable < String > objectIDs ,
560
+ public async Task < List < BatchResponse > > DeleteObjectsAsync ( string indexName , IEnumerable < String > objectIDs ,
558
561
RequestOptions options = null ,
559
562
CancellationToken cancellationToken = default )
560
563
{
561
- return await ChunkedBatchAsync ( indexName , objectIDs . Select ( id => new { objectID = id } ) , Action . DeleteObject , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
564
+ return await ChunkedBatchAsync ( indexName , objectIDs . Select ( id => new { objectID = id } ) , Action . DeleteObject , false , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
562
565
}
563
566
564
567
/// <summary>
@@ -569,11 +572,11 @@ public async Task<List<BatchResponse>> DeleteObjects(string indexName, IEnumerab
569
572
/// <param name="createIfNotExists">To be provided if non-existing objects are passed, otherwise, the call will fail.</param>
570
573
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
571
574
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
572
- public async Task < List < BatchResponse > > PartialUpdateObjects < T > ( string indexName , IEnumerable < T > objects , bool createIfNotExists ,
575
+ public async Task < List < BatchResponse > > PartialUpdateObjectsAsync < T > ( string indexName , IEnumerable < T > objects , bool createIfNotExists ,
573
576
RequestOptions options = null ,
574
577
CancellationToken cancellationToken = default ) where T : class
575
578
{
576
- return await ChunkedBatchAsync ( indexName , objects , createIfNotExists ? Action . PartialUpdateObject : Action . PartialUpdateObjectNoCreate , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
579
+ return await ChunkedBatchAsync ( indexName , objects , createIfNotExists ? Action . PartialUpdateObject : Action . PartialUpdateObjectNoCreate , false , 1000 , options , cancellationToken ) . ConfigureAwait ( false ) ;
577
580
}
578
581
579
582
private static async Task < List < TU > > CreateIterable < TU > ( Func < TU , Task < TU > > executeQuery ,
0 commit comments