You are here

function search_api_solr_update_8313 in Search API Solr 8.3

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

Distinguish between simplified and traditional Chinese.

File

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

Code

function search_api_solr_update_8313() {
  foreach (search_api_solr_update_helper_get_field_type_configs() as $field_type_name => $field_type_config) {
    if ('zh-hans' === $field_type_config['field_type_language_code']) {
      if (!empty($field_type_config['field_type'])) {
        foreach ($field_type_config['field_type'] as &$components) {
          if (is_array($components)) {
            foreach ($components as &$analyzers) {
              if ('org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer' !== $analyzers['tokenizer']['class']) {
                $analyzers['tokenizer']['class'] = 'org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer';
              }
              foreach ($analyzers['filters'] as $key => $filter) {
                if ('solr.CJKBigramFilterFactory' === $filter['class']) {
                  unset($analyzers['filters'][$key]);
                }
              }
            }
          }
        }
      }
      if (!empty($field_type_config['spellcheck_field_type'])) {
        foreach ($field_type_config['spellcheck_field_type'] as &$components) {
          if (is_array($components) && 'org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer' !== $components['tokenizer']['class']) {
            $components['tokenizer']['class'] = 'org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer';
          }
        }
      }
      search_api_solr_update_helper_save_field_type_config($field_type_name, $field_type_config);
    }
  }
}