【发布时间】:2016-04-02 11:05:07
【问题描述】:
我希望 Solr 4 以两种方式返回给定同义词列表的同义词。
索引内容
Nice villa front of the sea
Looking for condo around 2 billions $
Superb house with 3 bedrooms
Flat for sale
synonyms.txt
#Equivalent synonyms may be separated with commas and give
#no explicit mapping. In this case the mapping behavior will
#be taken from the expand parameter in the schema. This allows
#the same synonym file to be used in different synonym handling strategies.
villa, house, home, condo, appartement, residence, flat
schema.xml
<analyzer type="index">
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" />
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="false"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
其实:
搜索“别墅”返回所有结果,但如果我在 Synonyms.txt 中搜索任何其他单词,除了相应的句子之外,我什么也得不到。
即平回报:
Flat for sale
即房屋回报:
Superb house with 3 bedrooms
我希望所有同义词(公寓、房子、公寓等)都返回与“别墅”关键字相同的结果。
【问题讨论】:
-
同义词过滤器应该在分词器之后 - 尝试移动它,看看是否有帮助(因为在分词发生之前您不会有一个由单独的令牌组成的流)。