diff --git a/config/schema/search_api.processor.schema.yml b/config/schema/search_api.processor.schema.yml
index 661b85c..5338e4b 100644
--- a/config/schema/search_api.processor.schema.yml
+++ b/config/schema/search_api.processor.schema.yml
@@ -28,6 +28,17 @@ plugin.plugin_configuration.search_api_processor.*:
 
 # Definitions for individual processors
 
+plugin.plugin_configuration.search_api_processor.hierarchy:
+  type: search_api.default_processor_configuration
+  label: 'Hierarchy processor configuration'
+  mapping:
+    fields:
+      type: sequence
+      label: 'Fields for which to add the hierarchy'
+      sequence:
+        type: string
+        label: 'Field ID'
+
 plugin.plugin_configuration.search_api_processor.highlight:
   type: search_api.default_processor_configuration
   label: 'Highlight processor configuration'
diff --git a/src/Plugin/search_api/processor/AddHierarchy.php b/src/Plugin/search_api/processor/AddHierarchy.php
new file mode 100644
index 0000000..24f392d
--- /dev/null
+++ b/src/Plugin/search_api/processor/AddHierarchy.php
@@ -0,0 +1,308 @@
+<?php
+
+namespace Drupal\search_api\Plugin\search_api\processor;
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Entity\ContentEntityInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
+use Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Plugin\PluginFormInterface;
+use Drupal\Core\TypedData\ComplexDataDefinitionInterface;
+use Drupal\search_api\IndexInterface;
+use Drupal\search_api\Item\FieldInterface;
+use Drupal\search_api\Item\ItemInterface;
+use Drupal\search_api\Plugin\PluginFormTrait;
+use Drupal\search_api\Processor\ProcessorPluginBase;
+use Drupal\search_api\Utility\FieldsHelperInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * @SearchApiProcessor(
+ *   id = "hierarchy",
+ *   label = @Translation("Index hierarchy"),
+ *   description = @Translation("Allows the indexing of values along with all their ancestors for hierarchical fields (like taxonomy term references)"),
+ *   stages = {
+ *     "preprocess_index" = -45
+ *   }
+ * )
+ */
+class AddHierarchy extends ProcessorPluginBase implements PluginFormInterface {
+
+  use PluginFormTrait;
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface|null
+   */
+  protected $entityTypeManager;
+
+  /**
+   * The fields helper.
+   *
+   * @var \Drupal\search_api\Utility\FieldsHelperInterface|null
+   */
+  protected static $fieldsHelper;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) {
+    /** @var static $processor */
+    $processor = parent::create($container, $configuration, $pluginId, $pluginDefinition);
+
+    $processor->setEntityTypeManager($container->get('entity_type.manager'));
+    static::setFieldsHelper($container->get('search_api.fields_helper'));
+
+    return $processor;
+  }
+
+  /**
+   * Retrieves the fields helper.
+   *
+   * @return \Drupal\search_api\Utility\FieldsHelperInterface
+   *   The fields helper.
+   */
+  public static function getFieldsHelper() {
+    return static::$fieldsHelper ?: \Drupal::service('search_api.fields_helper');
+  }
+
+  /**
+   * Sets the fields helper.
+   *
+   * @param \Drupal\search_api\Utility\FieldsHelperInterface $fieldsHelper
+   *   The new fields helper.
+   */
+  public static function setFieldsHelper(FieldsHelperInterface $fieldsHelper) {
+    static::$fieldsHelper = $fieldsHelper;
+  }
+
+  /**
+   * Retrieves the entity type manager service.
+   *
+   * @return \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager service.
+   */
+  public function getEntityTypeManager() {
+    return $this->entityTypeManager ?: \Drupal::entityTypeManager();
+  }
+
+  /**
+   * Sets the entity type manager service.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
+   *   The entity type manager service.
+   *
+   * @return $this
+   */
+  public function setEntityTypeManager(EntityTypeManagerInterface $entityTypeManager) {
+    $this->entityTypeManager = $entityTypeManager;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function supportsIndex(IndexInterface $index) {
+    return (bool) static::getHierarchyFields($index);
+  }
+
+  /**
+   * Finds all (potentially) hierarchical fields for the given index.
+   *
+   * Fields are returned if:
+   * - they point to an entity type; and
+   * - that entity type contains a property referencing the same type of entity
+   *   (so that a hierarchy could be built from that nested property).
+   *
+   * @param \Drupal\search_api\IndexInterface $index
+   *   The index for which hierarchical fields should be found.
+   *
+   * @return string[][]
+   *   An array containing all fields of the index for which hierarchical data
+   *   might be retrievable. The keys are those field's IDs, the values are
+   *   associative arrays containing the nested properties of those fields from
+   *   which a hierarchy might be constructed, with the property paths as the
+   *   keys and labels as the values.
+   */
+  protected static function getHierarchyFields(IndexInterface $index) {
+    $fieldOptions = array();
+
+    foreach ($index->getFields() as $field_id => $field) {
+      $definition = $field->getDataDefinition();
+      if ($definition instanceof ComplexDataDefinitionInterface) {
+        $properties = $definition->getPropertyDefinitions();
+        // The property might be an entity data definition itself.
+        $properties[''] = $definition;
+        foreach ($properties as $property) {
+          $property_label = $property->getLabel();
+          $property = static::$fieldsHelper->getInnerProperty($property);
+          if ($property instanceof EntityDataDefinitionInterface) {
+            $entity_type_id = $property->getEntityTypeId();
+            foreach ($property->getPropertyDefinitions() as $name_2 => $property_2) {
+              $property_2_label = $property_2->getLabel();
+              $property_2 = static::$fieldsHelper->getInnerProperty($property_2);
+              if ($property_2 instanceof EntityDataDefinitionInterface) {
+                if ($property_2->getEntityTypeId() == $entity_type_id) {
+                  $fieldOptions[$field_id]["$entity_type_id-$name_2"] = Html::escape($property_label . ' » ' . $property_2_label);
+                }
+              }
+              elseif ($property_2 instanceof ComplexDataDefinitionInterface) {
+                foreach ($property_2->getPropertyDefinitions() as $property_3) {
+                  $property_3 = static::$fieldsHelper->getInnerProperty($property_3);
+                  if ($property_3 instanceof EntityDataDefinitionInterface) {
+                    if ($property_3->getEntityTypeId() == $entity_type_id) {
+                      $fieldOptions[$field_id]["$entity_type_id-$name_2"] = Html::escape($property_label . ' » ' . $property_2_label);
+                      break;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
+    return $fieldOptions;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function defaultConfiguration() {
+    return array(
+      'fields' => array(),
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildConfigurationForm(array $form, FormStateInterface $formState) {
+    $form['#description'] = $this->t('Select the fields to which hierarchical data should be added.');
+
+    foreach (static::getHierarchyFields($this->index) as $field_id => $options) {
+      $enabled = !empty($this->configuration['fields'][$field_id]);
+      $form['fields'][$field_id]['status'] = array(
+        '#type' => 'checkbox',
+        '#title' => $this->index->getField($field_id)->getLabel(),
+        '#default_value' => $enabled,
+      );
+      reset($options);
+      $form['fields'][$field_id]['property'] = array(
+        '#type' => 'radios',
+        '#title' => $this->t('Hierarchy property to use'),
+        '#description' => $this->t("This field has several nested properties which look like they might contain hierarchy data for the field. Please pick the one that should be used."),
+        '#options' => $options,
+        '#default_value' => $enabled ? $this->configuration['fields'][$field_id] : key($options),
+        '#access' => count($options) > 1,
+        '#states' => array(
+          'visible' => array(
+            // @todo This shouldn't be dependent on the form array structure.
+            //   Use the '#process' trick instead.
+            ":input[name=\"processors[hierarchy][settings][fields][$field_id][status]\"]" => array(
+              'checked' => TRUE,
+            ),
+          ),
+        ),
+      );
+    }
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateConfigurationForm(array &$form, FormStateInterface $formState) {
+    $fields = array();
+    foreach ($formState->getValue('fields', array()) as $field_id => $values) {
+      if (!empty($values['status'])) {
+        if (empty($values['property'])) {
+          $formState->setError($form['fields'][$field_id]['property'], $this->t('You need to select a nested property to use for the hierarchy data.'));
+        }
+        else {
+          $fields[$field_id] = $values['property'];
+        }
+      }
+    }
+    $formState->setValue('fields', $fields);
+    if (!$fields) {
+      $formState->setError($form['fields'], $this->t('You need to select at least one field for which to add hierarchy data.'));
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function preprocessIndexItems(array $items) {
+    /** @var \Drupal\search_api\Item\ItemInterface $item */
+    foreach ($items as $item) {
+      foreach ($this->configuration['fields'] as $field_id => $property_specifier) {
+        $field = $item->getField($field_id);
+        if (!$field) {
+          continue;
+        }
+        list ($entity_type_id, $property) = explode('-', $property_specifier);
+        foreach ($field->getValues() as $entity_id) {
+          $this->addHierarchyValues($entity_type_id, $entity_id, $property, $field);
+        }
+      }
+    }
+  }
+
+  /**
+   * Adds all ancestors' IDs of the given entity to the given field.
+   *
+   * @param string $entityTypeId
+   *   The entity type ID.
+   * @param mixed $entityId
+   *   The ID of the entity for which ancestors should be found.
+   * @param string $property
+   *   The name of the property on the entity type which contains the references
+   *   to the parent entities.
+   * @param \Drupal\search_api\Item\FieldInterface $field
+   *   The field to which values should be added.
+   */
+  protected function addHierarchyValues($entityTypeId, $entityId, $property, FieldInterface $field) {
+    if ("$entityTypeId-$property" == 'taxonomy_term-parent') {
+      /** @var \Drupal\taxonomy\TermStorageInterface $entityStorage */
+      $entityStorage = $this->getEntityTypeManager()
+        ->getStorage('taxonomy_term');
+      $parents = array();
+      foreach ($entityStorage->loadParents($entityId) as $term) {
+        $parents[] = $term->id();
+      }
+    }
+    else {
+      $entity = $this->getEntityTypeManager()
+        ->getStorage($entityTypeId)
+        ->load($entityId);
+      $parents = array();
+      if ($entity instanceof ContentEntityInterface) {
+        try {
+          foreach ($entity->get($property) as $data) {
+            $values = static::getFieldsHelper()->extractFieldValues($data);
+            $parents = array_merge($parents, $values);
+          }
+        }
+        catch (\InvalidArgumentException $e) {
+          // Might happen, for example, if the property only exists on a certain
+          // bundle, and this entity has the wrong one.
+        }
+      }
+    }
+
+    foreach ($parents as $parent) {
+      if (!in_array($parent, $field->getValues())) {
+        $field->addValue($parent);
+        $this->addHierarchyValues($entityTypeId, $parent, $property, $field);
+      }
+    }
+  }
+
+}
diff --git a/src/Tests/ProcessorIntegrationTest.php b/src/Tests/ProcessorIntegrationTest.php
index cbd5192..dbd4b53 100644
--- a/src/Tests/ProcessorIntegrationTest.php
+++ b/src/Tests/ProcessorIntegrationTest.php
@@ -127,6 +127,13 @@ public function testProcessorIntegration() {
     sort($actual_processors);
     $this->assertEqual($enabled, $actual_processors);
 
+    $this->checkAddHierarchyIntegration();
+    $enabled[] = 'hierarchy';
+    sort($enabled);
+    $actual_processors = array_keys($this->loadIndex()->getProcessors());
+    sort($actual_processors);
+    $this->assertEqual($enabled, $actual_processors);
+
     // The 'add_url' processor is not available to be removed because it's
     // locked.
     $this->checkUrlFieldIntegration();
@@ -400,6 +407,18 @@ public function checkTransliterationIntegration() {
   }
 
   /**
+   * Tests the hierarchy processor.
+   */
+  protected function checkAddHierarchyIntegration() {
+    $configuration = array(
+      'hierarchy_fields' => array(
+        'uid' => 'uid',
+      ),
+    );
+    $this->editSettingsForm($configuration, 'hierarchy');
+  }
+
+  /**
    * Tests the integration of the "URL field" processor.
    */
   public function checkUrlFieldIntegration() {
diff --git a/tests/src/Kernel/Processor/AddHierarchyTest.php b/tests/src/Kernel/Processor/AddHierarchyTest.php
new file mode 100644
index 0000000..d9a52f7
--- /dev/null
+++ b/tests/src/Kernel/Processor/AddHierarchyTest.php
@@ -0,0 +1,298 @@
+<?php
+
+namespace Drupal\Tests\search_api\Kernel\Processor;
+
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
+use Drupal\node\Entity\NodeType;
+use Drupal\search_api\Item\Field;
+use Drupal\search_api\Query\Query;
+use Drupal\simpletest\NodeCreationTrait;
+use Drupal\taxonomy\Tests\TaxonomyTestTrait;
+use Drupal\Tests\search_api\Kernel\ResultsTrait;
+
+/**
+ * Tests the "Hierarchy" processor.
+ *
+ * @see \Drupal\search_api\Plugin\search_api\processor\AddHierarchy
+ *
+ * @group search_api
+ *
+ * @coversDefaultClass \Drupal\search_api\Plugin\search_api\processor\AddHierarchy
+ */
+class AddHierarchyTest extends ProcessorTestBase {
+
+  use NodeCreationTrait;
+  use EntityReferenceTestTrait;
+  use ResultsTrait;
+  use TaxonomyTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = array(
+    'filter',
+    'taxonomy',
+  );
+
+  /**
+   * A hierarchy to test.
+   */
+  protected static $hierarchy = array(
+    'fruit' => array(
+      'apple',
+      'pear'
+    ),
+    'vegetable' => array(
+      'radish',
+      'turnip',
+    ),
+  );
+
+  /**
+   * The nodes created for testing.
+   *
+   * @var \Drupal\node\NodeInterface[]
+   */
+  protected $nodes = array();
+
+  /**
+   * Hierarchical taxonomy terms.
+   *
+   * This is keyed by "type.item", for example: "fruit.pear".
+   *
+   * @var \Drupal\taxonomy\TermInterface[]
+   */
+  protected $terms = array();
+
+  /**
+   * Vocabulary to test with when using taxonomy for the hierarchy.
+   *
+   * @var \Drupal\taxonomy\VocabularyInterface
+   */
+  protected $vocabulary;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUp($processor = NULL) {
+    parent::setUp('hierarchy');
+
+    $this->installConfig(['filter']);
+    $this->installEntitySchema('taxonomy_term');
+    $this->createTaxonomyHierarchy();
+
+    // Create a node type for testing.
+    $type = NodeType::create(array(
+      'type' => 'page',
+      'name' => 'page',
+    ));
+    $type->save();
+
+    // Add the taxonomy field to page type.
+    $this->createEntityReferenceField(
+      'node',
+      'page',
+      'term_field',
+      NULL,
+      'taxonomy_term',
+      'default',
+      array(),
+      FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED
+    );
+
+    // Add a generic entity reference field.
+    $this->createEntityReferenceField(
+      'node',
+      'page',
+      'parent_reference',
+      NULL,
+      'node',
+      'default',
+      array()
+    );
+
+    // Index the taxonomy field.
+    $term_field = new Field($this->index, 'term_field');
+    $term_field->setType('integer');
+    $term_field->setPropertyPath('term_field');
+    $term_field->setDatasourceId('entity:node');
+    $term_field->setLabel('Terms');
+    $this->index->addField($term_field);
+    $this->index->save();
+
+    // Index the entity reference field.
+    $reference_field = new Field($this->index, 'parent_reference');
+    $reference_field->setType('integer');
+    $reference_field->setPropertyPath('parent_reference');
+    $reference_field->setDatasourceId('entity:node');
+    $reference_field->setLabel('Parent page');
+    $this->index->addField($reference_field);
+    $this->index->save();
+
+    // Setup a node index.
+    $datasources['entity:node'] = $this->index->createPlugin('datasource', 'entity:node');
+    $this->index->setDatasources($datasources);
+    $this->index->save();
+#    $this->index->removeDatasource('entity:comment')->save();
+    $this->container->get('search_api.index_task_manager')->addItemsAll($this->index);
+    $index_storage = $this->container->get('entity_type.manager')->getStorage('search_api_index');
+    $index_storage->resetCache(array($this->index->id()));
+    $this->index = $index_storage->load($this->index->id());
+  }
+
+  /**
+   * Helper function to create the hierarchy with taxonomy terms.
+   */
+  protected function createTaxonomyHierarchy() {
+    $this->vocabulary = $this->createVocabulary();
+
+    foreach (static::$hierarchy as $type => $items) {
+      // Add the 'type' item, and nest items underneath.
+      $this->terms[$type] = $type_term = $this->createTerm($this->vocabulary, array(
+        'name' => $type,
+      ));
+      foreach ($items as $item) {
+        $this->terms["$type.$item"] = $this->createTerm($this->vocabulary, array(
+          'name' => $item,
+          'parent' => $type_term,
+        ));
+      }
+    }
+  }
+
+  /**
+   * Tests taxonomy-based hierarchy indexing.
+   *
+   * @covers ::preprocessIndexItems
+   */
+  public function testPreprocessIndexItemsTaxonomy() {
+    // Add hierarchical terms to 3 nodes.
+    foreach (array('vegetable.turnip', 'vegetable', 'fruit.pear') as $i => $term) {
+      $this->nodes[$i] = $this->createNode(array(
+        'type' => 'page',
+        'term_field' => array(
+          'target_id' => $this->terms[$term]->id(),
+        ),
+      ));
+    }
+    $this->index->reindex();
+    $this->index->indexItems();
+
+    // By default, hierarchy is not indexed, so a search for 'vegetable' should
+    // only return node 2.
+    $query = new Query($this->index);
+    $query->addCondition('term_field', $this->terms['vegetable']->id());
+    $result = $query->execute();
+    $expected = array('node' => array(1));
+    $this->assertResults($result, $expected);
+
+    // Enable hierarchical indexing.
+    $processor = $this->index->getProcessor('hierarchy');
+    $processor->setConfiguration(array(
+      'fields' => array(
+        'term_field' => 'taxonomy_term-parent',
+      ),
+    ));
+    $this->index->save();
+    $this->index->indexItems();
+
+    // Query for "vegetable" should return 2 items:
+    // Node 1 is "vegetable.turnip" and node 2 is just "vegetable".
+    $query = new Query($this->index);
+    $query->addCondition('term_field', $this->terms['vegetable']->id());
+    $result = $query->execute();
+    $expected = array('node' => array(0, 1));
+    $this->assertResults($result, $expected);
+
+    // A search for just turnips should return node 1 only.
+    $query = new Query($this->index);
+    $query->addCondition('term_field', $this->terms['vegetable.turnip']->id());
+    $result = $query->execute();
+    $expected = array('node' => array(0));
+    $this->assertResults($result, $expected);
+
+    // Also add a term with multiple parents.
+    $this->terms['avocado'] = $this->createTerm($this->vocabulary, array(
+      'name' => 'Avocado',
+      'parent' => array($this->terms['fruit']->id(), $this->terms['vegetable']->id()),
+    ));
+    $this->nodes[3] = $this->createNode(array(
+      'type' => 'page',
+      'term_field' => array(
+        'target_id' => $this->terms['avocado']->id(),
+      ),
+    ));
+    $this->index->reindex();
+    $this->index->indexItems();
+
+    // Searching for 'fruit' or 'vegetable' should return this new node.
+    $query = new Query($this->index);
+    $query->addCondition('term_field', $this->terms['fruit']->id());
+    $result = $query->execute();
+    $expected = array('node' => array(2, 3));
+    $this->assertResults($result, $expected);
+
+    $query = new Query($this->index);
+    $query->addCondition('term_field', $this->terms['vegetable']->id());
+    $result = $query->execute();
+    $expected = array('node' => array(0, 1, 3));
+    $this->assertResults($result, $expected);
+  }
+
+  /**
+   * Tests non-taxonomy-based hierarchy.
+   *
+   * @covers ::preprocessIndexItems
+   * @covers ::addHierarchyValues
+   */
+  public function testPreprocessIndexItems() {
+    // Setup the nodes to follow the hierarchy.
+    foreach (static::$hierarchy as $type => $items) {
+      $this->nodes[] = $type_node = $this->createNode(array(
+        'title' => $type,
+      ));
+      foreach ($items as $item) {
+        $this->nodes[] = $this->createNode(array(
+          'title' => $item,
+          'parent_reference' => array('target_id' => $type_node->id()),
+        ));
+      }
+    }
+    // Add a third tier of hierarchy for specific types of radishes.
+    foreach (array('Cherry Belle', 'Snow Belle', 'Daikon') as $item) {
+      $this->nodes[] = $this->createNode(array(
+        'title' => $item,
+        'parent_reference' => array('target_id' => $this->nodes[5]->id()),
+      ));
+    }
+    $this->index->reindex();
+    $this->index->indexItems();
+
+    // Initially hierarchy is excluded, so "vegetable" should only return nodes
+    // 5 and 6.
+    $query = new Query($this->index);
+    $query->addCondition('parent_reference', $this->nodes[3]->id());
+    $result = $query->execute();
+    $expected = array('node' => array(4, 5));
+    $this->assertResults($result, $expected);
+
+    // Enable hierarchical indexing.
+    $processor = $this->index->getProcessor('hierarchy');
+    $processor->setConfiguration(array(
+      'fields' => array(
+        'parent_reference' => 'node-parent_reference',
+      ),
+    ));
+    $this->index->save();
+    $this->index->indexItems();
+
+    // A search for "vegetable" should now include the hierarchy.
+    $query = new Query($this->index);
+    $query->addCondition('parent_reference', $this->nodes[3]->id());
+    $result = $query->execute();
+    $expected = array('node' => array(4, 5, 6, 7, 8));
+    $this->assertResults($result, $expected);
+  }
+
+}
