You are here

public static function Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName in Search API Solr 8.3

Same name and namespace in other branches
  1. 8.2 src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName()
  2. 4.x src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName()

Maps a Solr field name to its language-specific equivalent.

For example the dynamic field tm_* will become tm;en* for English. Following this pattern we also have fall backs automatically:

  • tm;de-AT_*
  • tm;de_*
  • tm_*

This concept bases on the fact that "longer patterns will be matched first. If equal size patterns both match,the first appearing in the schema will be used." This is not obvious from the example above. But you need to take into account that the real field name for solr will be encoded. So the real values for the example above are:

  • tm_X3b_de_X2d_AT_*
  • tm_X3b_de_*
  • tm_*

Parameters

string $field_name: The field name.

string $language_id: The Drupal language code.

Return value

string The language-specific name.

See also

\Drupal\search_api_solr\Utility\Utility::encodeSolrName()

https://wiki.apache.org/solr/SchemaXml#Dynamic_fields

File

src/Utility/Utility.php, line 332

Class

Utility
Provides various helper functions for Solr backends.

Namespace

Drupal\search_api_solr\Utility

Code

public static function getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName($field_name, $language_id) {
  if ('twm_suggest' === $field_name) {
    return 'twm_suggest';
  }
  return Utility::modifySolrDynamicFieldName($field_name, '@^([a-z]+)_@', '$1' . SolrBackendInterface::SEARCH_API_SOLR_LANGUAGE_SEPARATOR . $language_id . '_');
}