@@ -34,22 +34,22 @@ private static async Task<IndexDocumentsResult> ExponentialBackoffAsync(SearchCl
3434
3535 var failedDocuments = result . Results . Where ( r => r . Succeeded != true ) . ToList ( ) ;
3636
37+ // handle partial failure
3738 if ( failedDocuments . Count > 0 )
3839 {
39- Console . WriteLine ( "BATCH STARTING AT DOC {0}:" , id ) ;
40- Console . WriteLine ( "[Attempt: {0} of {1} Failed] - Error: {2} \n " , attempts , maxRetryAttempts ) ;
41-
40+
4241 if ( attempts == maxRetryAttempts )
4342 {
44- Console . WriteLine ( "BATCH STARTING AT DOC {0}:" , id ) ;
4543 Console . WriteLine ( "[MAX RETRIES HIT] - Giving up on the batch starting at {0}" , id ) ;
4644 break ;
4745 }
4846 else
4947 {
50- Console . WriteLine ( "BATCH STARTING AT DOC {0}:" , id ) ;
51- Console . WriteLine ( "[Attempt: {0} of {1} Failed] - Error: {2} \n " , attempts , maxRetryAttempts ) ;
52- Console . WriteLine ( "{0} documents failed:" , failedDocuments . Count ) ;
48+ Console . WriteLine ( "[Batch starting at doc {0} had partial failure]" , id ) ;
49+ //Console.WriteLine("[Attempt: {0} of {1} Failed]", attempts, maxRetryAttempts);
50+ Console . WriteLine ( "[Retrying {0} failed documents] \n " , failedDocuments . Count ) ;
51+
52+ // creating a batch of failed documents to retry
5353 var failedDocumentKeys = failedDocuments . Select ( doc => doc . Key ) . ToList ( ) ;
5454 hotels = hotels . Where ( h => failedDocumentKeys . Contains ( h . HotelId ) ) . ToList ( ) ;
5555 batch = IndexDocumentsBatch . Upload ( hotels ) ;
@@ -65,8 +65,9 @@ private static async Task<IndexDocumentsResult> ExponentialBackoffAsync(SearchCl
6565 }
6666 catch ( RequestFailedException ex )
6767 {
68- Console . WriteLine ( "BATCH STARTING AT DOC {0}:" , id ) ;
69- Console . WriteLine ( "[Attempt: {0} of {1} Failed] - Error: {2} \n " , attempts , maxRetryAttempts , ex . Message ) ;
68+ Console . WriteLine ( "[Batch starting at doc {0} failed]" , id ) ;
69+ //Console.WriteLine("[Attempt: {0} of {1} Failed] - Error: {2} \n", attempts, maxRetryAttempts, ex.Message);
70+ Console . WriteLine ( "[Retrying entire batch] \n " ) ;
7071
7172 if ( attempts == maxRetryAttempts )
7273 {
0 commit comments