You are here

protected function SearchApiSolrMultilingualBackend::ensureAllMultilingualFieldsExist in Apache Solr Multilingual 8

1 call to SearchApiSolrMultilingualBackend::ensureAllMultilingualFieldsExist()
SearchApiSolrMultilingualBackend::alterSolrDocuments in src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php
Replaces language unspecific fulltext fields by language specific ones.

File

src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php, line 230
Contains \Drupal\as_search\Plugin\search_api\backend\ASSearchApiSolrBackend.

Class

SearchApiSolrMultilingualBackend
Plugin annotation @SearchApiBackend( id = "search_api_solr_multilingual", label = @Translation("Solr Multilingual"), description = @Translation("Index items using an Apache Solr Multilingual search server.") )

Namespace

Drupal\apachesolr_multilingual\Plugin\search_api\backend

Code

protected function ensureAllMultilingualFieldsExist(array $field_name_map_per_language, IndexInterface $index) {
  foreach ($field_name_map_per_language as $language_id => $map) {
    $field_type_name = 'text' . '_' . $language_id;
    $solr_field_type_name = SearchApiSolrUtility::encodeSolrDynamicFieldName($field_type_name);

    // handle field type
    $this
      ->ensureMultilingualFieldTypeExists($field_type_name, $solr_field_type_name, $index);

    // handle dynamic fields for multilingual tm and ts
    $multilingual_solr_field_name = SearchApiSolrUtility::encodeSolrDynamicFieldName('tm;' . $language_id . ';') . '*';
    $this
      ->ensureMultilingualFieldExists($multilingual_solr_field_name, $solr_field_type_name, $index);
    $multilingual_solr_field_name = SearchApiSolrUtility::encodeSolrDynamicFieldName('ts;' . $language_id . ';') . '*';
    $this
      ->ensureMultilingualFieldExists($multilingual_solr_field_name, $solr_field_type_name, $index);
    foreach ($map as $monolingual_solr_field_name => $multilingual_solr_field_name) {

      // do something field-specific if needed
    }
  }
}