diff --git a/config/schema/search_api.index.schema.yml b/config/schema/search_api.index.schema.yml index 51be9462..ed2d2e23 100644 --- a/config/schema/search_api.index.schema.yml +++ b/config/schema/search_api.index.schema.yml @@ -82,9 +82,9 @@ search_api.index.*: index_directly: type: boolean label: 'Index items immediately' - index_entity_references: + track_changes_in_references: type: boolean - label: 'Index entity references automatically' + label: 'Track changes in referenced entities' server: type: string label: 'Server ID' diff --git a/search_api.install b/search_api.install index 049963ea..75728ba2 100644 --- a/search_api.install +++ b/search_api.install @@ -342,7 +342,7 @@ function search_api_update_8107() { foreach ($config_factory->listAll('search_api.index.') as $index_id) { $index = $config_factory->getEditable($index_id); $options = $index->get('options'); - $options['index_entity_references'] = TRUE; + $options['track_changes_in_references'] = TRUE; $index->set('options', $options); // Mark the resulting configuration as trusted data. This avoids issues @@ -350,5 +350,5 @@ function search_api_update_8107() { $index->save(TRUE); } - return t('Enabled "Index entity references" on existing indexes.'); -} \ No newline at end of file + return t('Enabled "Track changes in referenced entities" on all existing search indexes.'); +} diff --git a/src/Entity/Index.php b/src/Entity/Index.php index 52de0157..f0c137dd 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -1228,7 +1228,7 @@ public function postCreate(EntityStorageInterface $storage) { $this->options += [ 'cron_limit' => $config->get('default_cron_limit'), 'index_directly' => TRUE, - 'index_entity_references' => TRUE, + 'track_changes_in_references' => TRUE, ]; } @@ -1271,7 +1271,7 @@ public function preSave(EntityStorageInterface $storage) { $this->options += [ 'cron_limit' => $config->get('default_cron_limit'), 'index_directly' => TRUE, - 'index_entity_references' => TRUE, + 'track_changes_in_references' => TRUE, ]; // Reset the static cache for getPropertyDefinitions() to make sure we don't diff --git a/src/Form/IndexForm.php b/src/Form/IndexForm.php index 7e6cadf8..7bb843e1 100644 --- a/src/Form/IndexForm.php +++ b/src/Form/IndexForm.php @@ -322,11 +322,11 @@ public function buildEntityForm(array &$form, FormStateInterface $form_state, In '#description' => $this->t('Immediately index new or updated items instead of waiting for the next cron run. This might have serious performance drawbacks and is generally not advised for larger sites.'), '#default_value' => $index->getOption('index_directly'), ]; - $form['options']['index_entity_references'] = [ + $form['options']['track_changes_in_references'] = [ '#type' => 'checkbox', - '#title' => $this->t('Index entity references automatically'), - '#description' => $this->t('Index entities that references the entity being updated. This might have serious performance drawbacks and is generally not advised for larger sites.'), - '#default_value' => $index->getOption('index_entity_references'), + '#title' => $this->t('Track changes in referenced entities'), + '#description' => $this->t('Automatically queue items for re-indexing if one of the field values indexed from entities they reference is changed. (For instance, when indexing the name of a taxonomy term in a Content index, this would lead to re-indexing when the term’s name changes.) Enabling this setting can lead to performance problems on large sites when saving some types of entities (an often-used taxonomy term in our example). However, when the setting is disabled, fields from referenced entities can go stale in the search index and other steps should be taken to prevent this.'), + '#default_value' => $index->getOption('track_changes_in_references'), ]; $form['options']['cron_limit'] = [ '#type' => 'textfield', diff --git a/src/IndexInterface.php b/src/IndexInterface.php index 5aece22a..e502f257 100644 --- a/src/IndexInterface.php +++ b/src/IndexInterface.php @@ -81,8 +81,8 @@ public function getOption($name, $default = NULL); * - cron_limit: The maximum number of items to be indexed per cron batch. * - index_directly: Boolean setting whether entities are indexed immediately * after they are created or updated. - * - index_entity_references: Boolean setting whether entities referecing the - * updated entity should be indexed/re-indexed or not. + * - track_changes_in_references: Boolean setting whether changes to + * referenced entities should be tracked by this index. * * @return array * An associative array of option values, keyed by the option name. diff --git a/src/Utility/TrackingHelper.php b/src/Utility/TrackingHelper.php index bd8d5f5f..cba74334 100644 --- a/src/Utility/TrackingHelper.php +++ b/src/Utility/TrackingHelper.php @@ -105,8 +105,9 @@ public function trackReferencedEntityUpdate(EntityInterface $entity, bool $delet // Original entity, if available. $original = $deleted ? NULL : ($entity->original ?? NULL); foreach ($indexes as $index) { - // Do not index entity references if the option has been disabled. - if (!$index->getOption('index_entity_references')) { + // Do not track changes to referenced entities if the option has been + // disabled. + if (!$index->getOption('track_changes_in_references')) { continue; }