You are here

function search_api_solr_update_8312 in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x search_api_solr.install \search_api_solr_update_8312()

Add language-specific unstemmed field types.

File

./search_api_solr.install, line 1249
Install, update and uninstall functions for the Search API Solr module.

Code

function search_api_solr_update_8312() {
  foreach (search_api_solr_update_helper_get_field_type_configs() as $field_type_name => $field_type_config) {
    if (!empty($field_type_config['custom_code'])) {
      continue;
    }
    if (!isset($field_type_config['unstemmed_field_type'])) {
      $temp_field_type = $field_type_config['field_type'];
      $stemmer_removed = FALSE;
      if (!empty($temp_field_type['analyzers'])) {
        foreach ($temp_field_type['analyzers'] as &$component) {
          if (!empty($component['filters'])) {
            foreach ($component['filters'] as $key => &$filter) {
              if ('solr.SnowballPorterFilterFactory' === $filter['class'] || strpos($filter['class'], 'Stem')) {
                unset($component['filters'][$key]);
                $stemmer_removed = TRUE;
              }
            }
          }
        }
      }
      if ($stemmer_removed) {
        $temp_field_type['name'] = 'text_unstemmed_' . $field_type_config['field_type_language_code'];
        $field_type_config['unstemmed_field_type'] = $temp_field_type;
        search_api_solr_update_helper_save_field_type_config($field_type_name, $field_type_config);
      }
    }
  }
}