diff --git a/plugins/arSolrPlugin/lib/arSolrPlugin.class.php b/plugins/arSolrPlugin/lib/arSolrPlugin.class.php index 6096954562..8d44467340 100644 --- a/plugins/arSolrPlugin/lib/arSolrPlugin.class.php +++ b/plugins/arSolrPlugin/lib/arSolrPlugin.class.php @@ -105,7 +105,7 @@ public function loadDiacriticsMappings() throw new sfException('You must create a diacritics_mapping.yml file.'); } - return sfYaml::load(array_shift($diacriticsFiles)); + return $diacriticsFiles; } public function flush() @@ -283,9 +283,6 @@ public static function makeHttpRequest($url, $method = 'GET', $body = null) */ protected function initialize() { - if (sfConfig::get('app_diacritics')) { - $this->config['index']['configuration']['analysis']['char_filter']['diacritics_lowercase'] = $this->loadDiacriticsMappings(); - } $url = $this->solrBaseUrl.'/solr/admin/collections?action=LIST'; $response = arSolrPlugin::makeHttpRequest($url); @@ -490,12 +487,9 @@ private function getFieldQuery($field, $type, $multiValue, $stored = true) private function setAnalyzers() { foreach ($this->config['index']['configuration']['analysis']['analyzer'] as $key => $analyzer) { + $charFilters = []; $filters = []; - if (sfConfig::get('app_diacritics')) { - $filters = array_push($filters, ['class' => 'diacritics_lowercase']); - } - $charFilters = []; foreach ($this->config['index']['configuration']['analysis']['char_filter'] as $charFilter) { array_push($charFilters, $charFilter); } @@ -504,6 +498,14 @@ private function setAnalyzers() array_push($filters, $this->config['index']['configuration']['analysis']['filter'][$filter]); } + if (sfConfig::get('app_diacritics')) { + $diacritics = $this->loadDiacriticsMappings(); + array_push($charFilters, [ + 'class' => 'solr.MappingCharFilterFactory', + 'mapping' => $diacritics[0], + ]); + } + $query = ['replace-field-type' => [ 'name' => $key, 'class' => 'solr.TextField',