You are here

protected function SearchApiSolrMultilingualBackend::createSolrMultilingualFieldType in Apache Solr Multilingual 8

1 call to SearchApiSolrMultilingualBackend::createSolrMultilingualFieldType()
SearchApiSolrMultilingualBackend::ensureMultilingualFieldTypeExists in src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php

File

src/Plugin/search_api/backend/SearchApiSolrMultilingualBackend.php, line 297
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 createSolrMultilingualFieldType($field_type_name, $solr_field_type_name, IndexInterface $index) {

  // Get the field type definition from Drupal.
  $field_type_entity = SolrFieldType::load($field_type_name);
  $field_type_definition = $field_type_entity
    ->getFieldType();
  $field_type_definition['name'] = $solr_field_type_name;
  $this
    ->tweakFilterConfig($field_type_definition['indexAnalyzer']['filters']);
  $this
    ->tweakFilterConfig($field_type_definition['queryAnalyzer']['filters']);

  // Send the config to Solr.
  $command_json = '{ "add-field-type": ' . Json::encode($field_type_definition) . '}';
  $command_json = str_replace('"' . $field_type_name . '"', '"' . $solr_field_type_name . '"', $command_json);
  return $this
    ->solrRestPost('schema', $command_json, $index);
}