You are here

function hook_search_api_solr_field_mapping_alter in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 search_api_solr.api.php \hook_search_api_solr_field_mapping_alter()
  2. 8.2 search_api_solr.api.php \hook_search_api_solr_field_mapping_alter()
  3. 7 search_api_solr.api.php \hook_search_api_solr_field_mapping_alter()
  4. 4.x search_api_solr.api.php \hook_search_api_solr_field_mapping_alter()

Change the way the index's field names are mapped to Solr field names.

Parameters

\Drupal\search_api\IndexInterface $index: The index whose field mappings are altered.

array $fields: An associative array containing the index field names mapped to their Solr counterparts. The special fields 'search_api_id' and 'search_api_relevance' are also included.

1 invocation of hook_search_api_solr_field_mapping_alter()
SearchApiSolrBackend::getSolrFieldNames in src/Plugin/search_api/backend/SearchApiSolrBackend.php
Creates a list of all indexed field names mapped to their Solr field names.

File

./search_api_solr.api.php, line 39
Hooks provided by the Search API Solr search module.

Code

function hook_search_api_solr_field_mapping_alter(\Drupal\search_api\IndexInterface $index, array &$fields) {
  if (in_array('entity:node', $index
    ->getDatasourceIds()) && isset($fields['entity:node|body'])) {
    $fields['entity:node|body'] = 'tm_entity$node|body_value';
  }
}