diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index 8d03bb8..3634d29 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -15,17 +15,20 @@ function apachesolr_index_entities($env_id, $limit) {
     // 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) {
       $documents = array_merge($documents, apachesolr_index_entity_to_documents($row, $env_id));
-  }
-
-    $indexed = apachesolr_index_send_to_solr($env_id, $documents);
-    if ($indexed !== FALSE && $indexed > 0) {
-      $entities_processed += count($rows);
-      $last_row = end($rows);
-      apachesolr_set_last_index_position($env_id, $entity_type, $last_row->changed, $last_row->entity_id);
-      apachesolr_set_last_index_updated($env_id, REQUEST_TIME);
+    }
+    
+    // When there are no documents to send we do not want to execute the
+    // indexing function either
+    if (!empty($documents)) {
+      $indexed = apachesolr_index_send_to_solr($env_id, $documents);
+      if ($indexed !== FALSE && $indexed > 0) {
+        $entities_processed += count($rows);
+        $last_row = end($rows);
+        apachesolr_set_last_index_position($env_id, $entity_type, $last_row->changed, $last_row->entity_id);
+        apachesolr_set_last_index_updated($env_id, REQUEST_TIME);
+      }
     }
   }
   return $entities_processed;
@@ -180,6 +183,10 @@ 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
+  if (empty($documents)) {
+    return FALSE;
+  }
 
   // Send the document off to Solr.
   watchdog('Apache Solr', 'Adding @count documents.', array('@count' => count($documents)));
