I am using Search API and Search API Solr modules on drupal 7. I have also drupal 8 and drupal 9 sites, and all those sites are indexed on the same solr index. So I need the same machine name for indexed fields on Solr index. For this purpose, I need to change marked machine names. Solr index field names are generated from those machine names. enter image description here For drupal 7 I can't find a field mapping solution like Search API field map module for drupal 8, 9. Is there any solution to override those fields' machine names in index creation? Thanks.

1 Answer 1


My answer I found in search_api_solr module search_api_solr.api.php file. I used hook_search_api_solr_field_mapping_alter

 * Change the way the index's field names are mapped to Solr field names.
 * @param SearchApiIndex $index
 *   The index whose field mappings are altered.
 * @param 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.
 function hook_search_api_solr_field_mapping_alter(SearchApiIndex $index, 
                                                               array &$fields) {
   if ($index->entity_type == 'node' && isset($fields['body:value'])) {
    $fields['body:value'] = 'tm_text';

Here you can add required Solr index field name('tm_text') for according field('body:value').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.