@@ -885,7 +885,10 @@ public IEnumerable<ReportInstance> GetLatestInstances(int id, int? ownerId = nul
885885
886886 // Determine index.
887887 var defaultIndex = filterSettings . SearchUnpublished ? _elasticOptions . ContentIndex : _elasticOptions . PublishedIndex ;
888- var content = await _elasticClient . SearchAsync < API . Areas . Services . Models . Content . ContentModel > ( defaultIndex , query ) ;
888+
889+ // Add retry logic for Elasticsearch query to handle failures
890+ var content = await RetryElasticsearchQueryAsync ( async ( ) =>
891+ await _elasticClient . SearchAsync < API . Areas . Services . Models . Content . ContentModel > ( defaultIndex , query ) ) ;
889892 var contentHits = content . Hits . Hits . ToArray ( ) ;
890893
891894 // Fetch custom content versions for the requestor.
@@ -940,6 +943,30 @@ public IEnumerable<ReportInstance> GetLatestInstances(int id, int? ownerId = nul
940943 return searchResults ;
941944 }
942945
946+ /// <summary>
947+ /// Retry Elasticsearch query once after 200ms to handle intermittent failures.
948+ /// This helps resolve issues like JSON parsing failures in BC Updates filtering.
949+ /// </summary>
950+ /// <typeparam name="T">The return type of the Elasticsearch operation</typeparam>
951+ /// <param name="operation">The Elasticsearch operation to retry</param>
952+ /// <returns>The result of the successful operation</returns>
953+ private async Task < T > RetryElasticsearchQueryAsync < T > ( Func < Task < T > > operation )
954+ {
955+ try
956+ {
957+ return await operation ( ) ;
958+ }
959+ catch ( Exception ex )
960+ {
961+ Logger . LogWarning ( ex ,
962+ "Elasticsearch query failed. Retrying in 200ms. Error: {ErrorMessage}" ,
963+ ex . Message ) ;
964+
965+ await Task . Delay ( 200 ) ;
966+ return await operation ( ) ;
967+ }
968+ }
969+
943970 /// <summary>
944971 /// Find content with Elasticsearch for the specified `reportInstance` and `section`.
945972 /// This method supports regenerating content within a section.
@@ -1061,7 +1088,8 @@ public IEnumerable<ReportInstance> GetLatestInstances(int id, int? ownerId = nul
10611088
10621089 // Determine index.
10631090 var defaultIndex = filterSettings . SearchUnpublished ? _elasticOptions . ContentIndex : _elasticOptions . PublishedIndex ;
1064- var content = await _elasticClient . SearchAsync < API . Areas . Services . Models . Content . ContentModel > ( defaultIndex , query ) ;
1091+ var content = await RetryElasticsearchQueryAsync ( async ( ) =>
1092+ await _elasticClient . SearchAsync < API . Areas . Services . Models . Content . ContentModel > ( defaultIndex , query ) ) ;
10651093
10661094 // Fetch custom content versions for the requestor.
10671095 var contentIds = content . Hits . Hits . Select ( h => h . Source . Id ) . Distinct ( ) . ToArray ( ) ;
0 commit comments