def bulk(client, actions, stats_only=False, **kwargs):
 (success, failed) = (0, 0)
 errors = []
 for (ok, item) in streaming_bulk(client, actions, **kwargs):
  if (not ok):
   if (not stats_only):
    errors.append(item)
   failed += 1
  else:
   success += 1
 return (success, (failed if stats_only else errors))

def bulk ( client , actions , stats_only = False , ** kwargs ) : ( success , failed ) = ( 0 , 0 ) errors = [ ] for ( ok , item ) in streaming_bulk ( client , actions , ** kwargs ) : if ( not ok ) : if ( not stats_only ) : errors . append ( item ) failed += 1 else : success += 1 return ( success , ( failed if stats_only else errors ) )
helper for the :meth:~elasticsearch .