You are here

public static function Utility::extractLanguageSpecificSolrDynamicFieldDefinition in Search API Multilingual Solr Search 8

Extracts the language-specific definition from a dynamic Solr field.

Parameters

string $field_name: The field name.

Return value

mixed The language-specific prefix as string or boolean FALSE if no prefix could be extracted.

1 call to Utility::extractLanguageSpecificSolrDynamicFieldDefinition()
UtilitiesTest::doDynamicFieldNameConversions in tests/src/Kernel/UtilitiesTest.php
Tests all conversion and extraction functions.

File

src/Utility/Utility.php, line 147

Class

Utility
Provides various helper functions for multilingual Solr backends.

Namespace

Drupal\search_api_solr_multilingual\Utility

Code

public static function extractLanguageSpecificSolrDynamicFieldDefinition($field_name) {
  $decoded_field_name = SearchApiSolrUtility::decodeSolrName($field_name);
  if (preg_match('@^[a-z]+' . SEARCH_API_SOLR_MULTILINGUAL_LANGUAGE_SEPARATOR . '[^_]+?_@', $decoded_field_name, $matches)) {
    return SearchApiSolrUtility::encodeSolrName($matches[0]) . '*';
  }
  return FALSE;
}