diff --git a/apachesolr.api.php b/apachesolr.api.php
index 75e6018..5ecc8fd 100644
--- a/apachesolr.api.php
+++ b/apachesolr.api.php
@@ -193,17 +193,56 @@ function hook_apachesolr_delete_by_query_alter($query) {
     $query .= ' AND hash:' . apachesolr_site_hash();
   }
 }
+/*
+ * This is the place to look for the replacement to hook_apachesolr_node_exclude
+ * You should define a replacement for the status callback and return
+ * FALSE for entities which you do not want to appear in the index and TRUE for
+ * those that you want to include
+ */
+
+/**
+ * This is invoked for each entity that is being inspected to be added to the
+ * index. if any module returns TRUE, the entity is skipped for indexing.
+ *
+ * @param integer $entity_id
+ * @param string $entity_type
+ * @param integer $row
+ *   A complete set of data from the indexing table.
+ * @param string $env_id
+ * @return boolean
+ */
+function hook_apachesolr_exclude($entity_id, $entity_type, $row, $env_id) {
+  // Never index media entities to core_1
+  if ($entity_type == 'media' && $env_id == 'core_1') {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * This is invoked for each entity from the type of ENTITY_TYPE that is being
+ * inspected to be added to the index. if any module returns TRUE, 
+ * the entity is skipped for indexing.
+ *
+ * @param integer $entity_id
+ * @param integer $row
+ *   A complete set of data from the indexing table.
+ * @param string $env_id
+ * @return boolean
+ */
+function hook_apachesolr_ENTITY_TYPE_exclude($entity_id, $row, $env_id) {
+  // Never index ENTITY_TYPE to core_1
+  if ($env_id == 'core_1') {
+    return TRUE;
+  }
+  return FALSE;
+}
 
 /**
  * Add information to index other entities.
  * There are some modules in http://drupal.org that can give a good example of
  * custom entity indexing such as apachesolr_user_indexer, apachesolr_term
  *
- * This is the place to look for the replacement to hook_apachesolr_node_exclude
- * You should define a replacement for the status callback and return
- * 0 for nodes which you do not want to appear in the index and 1 for nodes
- * that you do. See http://drupal.org/node/1474906 for an example.
- *
  * @param array $entity_info
  */
 function hook_apachesolr_entity_info_alter(&$entity_info) {
diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index 3c369b1..176b67a 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -9,14 +9,32 @@
  * Send up to $limit entities of each type into the index.
  */
 function apachesolr_index_entities($env_id, $limit) {
-  $entities_processed = 0;
+  $documents_submitted = 0;
   $entity_type = 'node';
   // With each pass through the callback, retrieve the next group of nids.
   $rows = apachesolr_index_get_entities_to_index($env_id, $entity_type, $limit);
   $documents = array();
   foreach ($rows as $row) {
     if (!empty($row->status)) {
-      $documents = array_merge($documents, apachesolr_index_entity_to_documents($row, $env_id));
+    // Let any module exclude this entity from the index.
+      $build_document = TRUE;
+      foreach (module_implements('apachesolr_exclude') as $module) {
+        $exclude = module_invoke($module, 'apachesolr_exclude', $row->entity_id, $entity_type, $row, $env_id);
+        // If the hook returns TRUE we should exclude the entity
+        if (!empty($exclude)) {
+          $build_document = FALSE;
+        }
+      }
+      foreach (module_implements('apachesolr_' . $entity_type . '_exclude') as $module) {
+        $exclude = module_invoke($module, 'apachesolr_' . $entity_type . '_exclude', $row->entity_id, $row, $env_id);
+        // If the hook returns TRUE we should exclude the entity
+        if (!empty($exclude)) {
+          $build_document = FALSE;
+        }
+      }
+      if ($build_document) {
+        $documents = array_merge($documents, apachesolr_index_entity_to_documents($row, $env_id));
+      }
     }
     else {
       // Delete the entity from our index if the status callback returned 0
@@ -25,7 +43,7 @@ function apachesolr_index_entities($env_id, $limit) {
   }
   $indexed = apachesolr_index_send_to_solr($env_id, $documents);
   if ($indexed !== FALSE) {
-    $entities_processed += count($rows);
+    $documents_submitted += count($documents);
     $index_position = apachesolr_get_last_index_position($env_id, $entity_type);
       $max_changed = $index_position['last_changed'];
       $max_entity_id = $index_position['last_entity_id'];
@@ -42,7 +60,7 @@ function apachesolr_index_entities($env_id, $limit) {
       apachesolr_set_last_index_position($env_id, $entity_type, $max_changed, $max_entity_id);
       apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME);
   }
-  return $entities_processed;
+  return $documents_submitted;
 }
 
 /**
@@ -63,7 +81,6 @@ function apachesolr_index_status($env_id) {
   // Get $last_entity_id and $last_change.
   extract(apachesolr_get_last_index_position($env_id, $entity_type));
 
-
   // Find the next batch of entities to index for this entity type.  Note that
   // for ordering we're grabbing the oldest first and then ordering by ID so
   // that we get a definitive order.
@@ -180,11 +197,6 @@ function apachesolr_index_entity_to_documents($item, $env_id) {
  * @return number indexed, or FALSE on failure.
  */
 function apachesolr_index_send_to_solr($env_id, $documents) {
-  // Do not index when we do not have any documents to send
-  if (empty($documents)) {
-    return FALSE;
-  }
-
   try {
     // Get the $solr object
     $solr = apachesolr_get_solr($env_id);
@@ -197,7 +209,11 @@ function apachesolr_index_send_to_solr($env_id, $documents) {
     watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR);
     return FALSE;
   }
-
+  // Do not index when we do not have any documents to send
+  // Send TRUE because this is not an error
+  if (empty($documents)) {
+    return TRUE;
+  }
   // Send the document off to Solr.
   watchdog('Apache Solr', 'Adding @count documents.', array('@count' => count($documents)));
   try {
@@ -347,8 +363,7 @@ function apachesolr_index_get_entities_to_index($env_id, $entity_type, $limit) {
   // Find the next batch of entities to index for this entity type.  Note that
   // for ordering we're grabbing the oldest first and then ordering by ID so
   // that we get a definitive order.
-  $query = "SELECT aie.entity_type, aie.entity_id, aie.changed, aie.bundle, aie.status
-   FROM {{$table}} aie
+  $query = "SELECT * FROM {{$table}} aie
    WHERE (aie.bundle IN (" . db_placeholders($bundles, 'varchar') . "))
    AND (aie.entity_type = '%s')
    AND ((aie.changed > %d) OR ((aie.changed <= %d) AND (aie.entity_id > %d)))";
