diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install
new file mode 100644
index 0000000..4030b8e
--- /dev/null
+++ b/core/modules/taxonomy/taxonomy.install
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the taxonomy module.
+ */
+
+/**
+ * Add unpublished nodes to the taxonomy index table.
+ */
+function taxonomy_update_8201(&$sandbox) {
+  if (!isset($sandbox['total'])) {
+    // Initialize state for future calls.
+    $sandbox['last'] = 0;
+    $sandbox['count'] = 0;
+
+    $query = db_select('node_field_data', 'n')
+      ->condition('n.status', NODE_NOT_PUBLISHED);
+    $sandbox['total'] = $query->countQuery()->execute()->fetchField();
+  }
+  if ($sandbox['total']) {
+    // Operate on every unpublished node, in batches.
+    $batch_size = 100;
+    $query = db_select('node_field_data', 'n');
+    $query
+      ->fields('n', array('nid'))
+      ->condition('n.nid', $sandbox['last'], '>')
+      ->condition('n.status', NODE_NOT_PUBLISHED)
+      ->orderBy('n.nid', 'ASC')
+      ->range(0, $batch_size);
+    $records = $query->execute();
+    // Build the taxonomy index for each node.
+    foreach ($records as $record) {
+      $node = node_load($record->nid);
+      taxonomy_build_node_index($node);
+      $sandbox['last'] = $record->nid;
+    }
+    $sandbox['count'] += $batch_size;
+  }
+  // Finish after all the unpublished nodes have been processed.
+  if ($sandbox['count'] < $sandbox['total']) {
+    $sandbox['#finished'] = FALSE;
+  }
+  else {
+    $sandbox['#finished'] = TRUE;
+  }
+}
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 4a93989..1af3ab0 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -505,10 +505,11 @@ function taxonomy_build_node_index($node) {
     return;
   }
 
-  $status = $node->isPublished();
-  $sticky = (int) $node->isSticky();
-  // We only maintain the taxonomy index for published nodes.
-  if ($status && $node->isDefaultRevision()) {
+  // We only maintain the taxonomy index for the default node revision.
+  if ($node->isDefaultRevision()) {
+    $status = (int) $node->isPublished();
+    $sticky = (int) $node->isSticky();
+
     // Collect a unique list of all the term IDs from all node fields.
     $tid_all = [];
     $entity_reference_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem';
@@ -530,7 +531,7 @@ function taxonomy_build_node_index($node) {
     if (!empty($tid_all)) {
       foreach ($tid_all as $tid) {
         db_merge('taxonomy_index')
-          ->key(['nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()])
+          ->key(['nid' => $node->id(), 'tid' => $tid, 'status' => $status])
           ->fields(['sticky' => $sticky, 'created' => $node->getCreatedTime()])
           ->execute();
       }
