Solr 变音处理
Solr Umlaut handling
我正在尝试在 Solr 中执行以下操作。
例如,我想在搜索时将 ü 和 ue 视为等同的。其他变音符号也类似。搜索 API 的用户应该能够使用其中任何一种进行搜索并仍然获得相同的结果。例如,使用 übersicht
和 uebersicht 搜索应该得到相同的结果
我看到了带有 German2 语言属性的 SnowballPorterFilterFactory。 German2 属性看起来是我需要的,但我想使用它而不必引入词干分析。
这可能吗
您可以使用
<filter class="solr.GermanNormalizationFilterFactory"/>
https://lucene.apache.org/core/4_0_0/analyzers-common/org/apache/lucene/analysis/de/GermanNormalizationFilter.html
这是这样工作的:
- 'ß' 替换为 'ss'
- 'ä'、'ö'、'ü'分别替换为 'a'、'o'、'u'。
- 'ae' 和 'oe' 分别替换为 'a' 和 'o'。
- 'ue' 在不跟在元音或 q 之后时被 'u' 替换。
您还可以将 <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/>
与您自己的映射文件一起使用。 https://lucene.apache.org/core/8_1_1/analyzers-common/org/apache/lucene/analysis/charfilter/MappingCharFilterFactory.html
mapping.txt示例:
“ü”=>“ue”
"ä" => "ae"
我正在尝试在 Solr 中执行以下操作。
例如,我想在搜索时将 ü 和 ue 视为等同的。其他变音符号也类似。搜索 API 的用户应该能够使用其中任何一种进行搜索并仍然获得相同的结果。例如,使用 übersicht
和 uebersicht 搜索应该得到相同的结果
我看到了带有 German2 语言属性的 SnowballPorterFilterFactory。 German2 属性看起来是我需要的,但我想使用它而不必引入词干分析。 这可能吗
您可以使用
<filter class="solr.GermanNormalizationFilterFactory"/>
https://lucene.apache.org/core/4_0_0/analyzers-common/org/apache/lucene/analysis/de/GermanNormalizationFilter.html
这是这样工作的:
- 'ß' 替换为 'ss'
- 'ä'、'ö'、'ü'分别替换为 'a'、'o'、'u'。
- 'ae' 和 'oe' 分别替换为 'a' 和 'o'。
- 'ue' 在不跟在元音或 q 之后时被 'u' 替换。
您还可以将 <charFilter class="solr.MappingCharFilterFactory" mapping="mapping.txt"/>
与您自己的映射文件一起使用。 https://lucene.apache.org/core/8_1_1/analyzers-common/org/apache/lucene/analysis/charfilter/MappingCharFilterFactory.html
mapping.txt示例:
“ü”=>“ue”
"ä" => "ae"