code: def index_model(index_name, adapter):
      ''' Indel all objects given a model'''
      model = adapter.model
      log.info('Indexing {0} objects'.format(model.__name__))
      qs = model.objects
      if hasattr(model.objects, 'visible'):
          qs = qs.visible()
      if adapter.exclude_fields:
          qs = qs.exclude(*adapter.exclude_fields)
  
      docs = iter_qs(qs, adapter)
      docs = iter_for_index(docs, index_name)
  
      for ok, info in streaming_bulk(es.client, docs, raise_on_error=False):
          if not ok:
              log.error('Unable to index %s "%s": %s', model.__name__,
                        info['index']['_id'], info['index']['error']f index_model(index_name, adapter):
      ''' Indel all objects given a model'''
      model = adapter.model
      log.info('Indexing {0} objects'.format(model.__name__))
      qs = model.objects
      if hasattr(model.objects, 'visible'):
          qs = qs.visible()
      if adapter.exclude_fields:
          qs = qs.exclude(*adapter.exclude_fields)
  
      docs = iter_qs(qs, adapter)
      docs = iter_for_index(docs, index_name)
  
      for ok, info in streaming_bulk(es.client, docs, raise_on_error=False):
          if not ok:
              log.error('Unable to index %s "%s": %s', model.__name__,
                        info['index']['_id'], info['index']['error'])
docs: Indel all objects given a model