You are here

function search_api_solr_views_data_alter in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 search_api_solr.module \search_api_solr_views_data_alter()
  2. 7 search_api_solr.views.inc \search_api_solr_views_data_alter()
  3. 4.x search_api_solr.module \search_api_solr_views_data_alter()

Implements hook_views_data_alter().

Remove fields from solr_document datasources from the views data. Datasource fields that have been added to the index would be duplicated in the Views Add fields list. Fields that aren't added to the index can't be displayed.

File

./search_api_solr.module, line 399

Code

function search_api_solr_views_data_alter(array &$data) {

  // @todo check for a search_api based view first.
  foreach ($data as $key => $fields) {
    if (preg_match('/search_api_datasource_(.+)_solr_document/', $key)) {
      unset($data[$key]);
    }
  }
}