@@ -528,23 +528,30 @@ def scan(
528
528
resp_failures = resp ["_shards" ].get ("failures" )
529
529
failures = []
530
530
if resp_failures is not None :
531
- for resp_failure in resp_failures :
532
- failure = "Failure type[%s] received with reason: %s" % (
533
- resp_failure ["reason" ]["type" ],
534
- resp_failure ["reason" ]["reason" ],
531
+ for i in range (5 ):
532
+ if i < len (resp_failures ):
533
+ failure = "Failure type[%s] received with reason: %s" % (
534
+ resp_failures [i ]["reason" ]["type" ],
535
+ resp_failures [i ]["reason" ]["reason" ],
536
+ )
537
+ failures .append (failure )
538
+ logger .warning (failure )
539
+
540
+ if len (resp_failures ) > 5 :
541
+ omitted_failures = len (resp_failures ) - 5
542
+ failures .append (
543
+ "...and %d more omitted failures" % omitted_failures
535
544
)
536
- failures .append (failure )
537
- logger .warning (failure )
538
545
if raise_on_error :
539
546
raise ScanError (
540
547
scroll_id ,
541
- "Scroll request has only succeeded on %d (+%d skiped ) shards out of %d.\n "
548
+ "Scroll request has only succeeded on %d (+%d skipped ) shards out of %d.\n "
542
549
"%s"
543
550
% (
544
551
resp ["_shards" ]["successful" ],
545
552
resp ["_shards" ]["skipped" ],
546
553
resp ["_shards" ]["total" ],
547
- "" .join (failures ),
554
+ "\n " .join (failures ),
548
555
),
549
556
)
550
557
resp = client .scroll (
0 commit comments