You are here

protected function SearchApiSolrBackend::indexFieldsUpdated in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::indexFieldsUpdated()
  2. 8 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::indexFieldsUpdated()
  3. 8.2 src/Plugin/search_api/backend/SearchApiSolrBackend.php \Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::indexFieldsUpdated()

Checks if the recently updated index had any fields changed.

Parameters

\Drupal\search_api\IndexInterface $index: The index that was just updated.

Return value

bool TRUE if any of the fields were updated, FALSE otherwise.

1 call to SearchApiSolrBackend::indexFieldsUpdated()
SearchApiSolrBackend::updateIndex in src/Plugin/search_api/backend/SearchApiSolrBackend.php

File

src/Plugin/search_api/backend/SearchApiSolrBackend.php, line 988

Class

SearchApiSolrBackend
Apache Solr backend for search api.

Namespace

Drupal\search_api_solr\Plugin\search_api\backend

Code

protected function indexFieldsUpdated(IndexInterface $index) {

  // Get the original index, before the update. If it cannot be found, err on
  // the side of caution.
  if (!isset($index->original)) {
    return TRUE;
  }

  /** @var \Drupal\search_api\IndexInterface $original */
  $original = $index->original;
  $old_fields = $original
    ->getFields();
  $new_fields = $index
    ->getFields();
  if (!$old_fields && !$new_fields) {
    return FALSE;
  }
  if (array_diff_key($old_fields, $new_fields) || array_diff_key($new_fields, $old_fields)) {
    return TRUE;
  }
  $old_field_names = $this
    ->getSolrFieldNames($original, TRUE);
  $new_field_names = $this
    ->getSolrFieldNames($index, TRUE);
  return $old_field_names != $new_field_names;
}