public static function Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName in Search API Multilingual Solr Search 8
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 langauge 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
4 calls to Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName()
- AbstractSearchApiSolrMultilingualBackend::alterSolrDocuments in src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php - Replaces language unspecific fulltext fields by language specific ones.
- AbstractSearchApiSolrMultilingualBackend::getLanguageSpecificSolrFieldNames in src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php - Gets a language-specific mapping from Drupal to Solr field names.
- AbstractSearchApiSolrMultilingualBackend::preQuery in src/
Plugin/ search_api/ backend/ AbstractSearchApiSolrMultilingualBackend.php - Modify the query before it is sent to solr.
- UtilitiesTest::doDynamicFieldNameConversions in tests/
src/ Kernel/ UtilitiesTest.php - Tests all conversion and extraction functions.
File
- src/
Utility/ Utility.php, line 52
Class
- Utility
- Provides various helper functions for multilingual Solr backends.
Namespace
Drupal\search_api_solr_multilingual\UtilityCode
public static function getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName($field_name, $language_id) {
return Utility::modifySolrDynamicFieldName($field_name, '@^([a-z]+)_@', '$1' . SEARCH_API_SOLR_MULTILINGUAL_LANGUAGE_SEPARATOR . $language_id . '_');
}