You are here

function search_api_solr_update_8305 in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 search_api_solr.install \search_api_solr_update_8305()

Add Dutch nouns and improve stemming for Dutch language.

File

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

Code

function search_api_solr_update_8305() {
  $nouns = '';
  foreach (search_api_solr_update_helper_get_field_type_configs() as $field_type_name => $field_type_config) {
    if (strpos($field_type_name, 'text_nl') !== FALSE) {
      $save = FALSE;
      if (!empty($field_type_config['field_type']) && !empty($field_type_config['field_type']['analyzers'])) {
        foreach ($field_type_config['field_type']['analyzers'] as &$component) {
          foreach ($component['filters'] as &$filter) {
            if ($filter['class'] === 'solr.SnowballPorterFilterFactory') {
              if ($filter['language'] === 'Dutch') {
                $filter['language'] = 'Kp';
                $save = TRUE;
              }
            }
          }
        }
      }
      if (!empty($field_type_config['text_files'])) {
        if (empty($field_type_config['text_files']['nouns']) || $field_type_config['text_files']['nouns'] == PHP_EOL) {
          if (!$nouns) {

            // We always use this hardcoded source file to have valid one for
            // different domains created by users, example:
            // text_nl_scientific_6_0_0.
            $filename = __DIR__ . '/config/optional/search_api_solr.solr_field_type.text_nl_7_0_0.yml';
            $nouns = Yaml::decode(file_get_contents($filename));
          }
          $field_type_config['text_files']['nouns'] = $nouns['text_files']['nouns'];
          $save = TRUE;
        }
      }
      if ($save) {
        search_api_solr_update_helper_save_field_type_config($field_type_name, $field_type_config);
      }
    }
  }
}