我正在尝试在 solr 中实现多词同义词,特别是类型
msc divina => divina
因此,如果用户输入“msc divina”,solr 应该只返回“divina”的结果。
schema.xml 中的定义如下所示:
<fieldType name="text_de" class="solr.TextField" positionIncrementGap="100"
autoGeneratePhraseQueries="true">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.SynonymFilterFactory"
synonyms="synonyms_de.txt"
ignoreCase="true"
expand="false" />
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords_de.txt"
enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1"
generateNumberParts="1"
catenateWords="1"
catenateNumbers="1"
catenateAll="0"
splitOnCaseChange="1" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.KeywordMarkerFilterFactory"
protected="protwords_de.txt" />
<filter class="solr.SnowballPorterFilterFactory" language="German2" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords_de.txt"
enablePositionIncrements="true" />
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="1" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.KeywordMarkerFilterFactory"
protected="protwords_de.txt" />
<filter class="solr.SnowballPorterFilterFactory" language="German2" />
</analyzer>
</fieldType>
它不起作用。如果我向查询分析器添加同义词过滤器,则搜索“msc divina”会返回“msc 和“divina”的每个匹配项。
我该如何解决这个问题?