我想在solr中使用同义词搜索多关键字。 但它不正确。
我在synonym.txt中为“multerm”设置了同义词“multi term”。而且我希望Solr为“multerm”创建查询短语,就像“field:”多项“〜0但是”字段:multi |字段:术语“。所以不能亲密搜索多项同义词。
任何人都有最好的方法在Solr中进行多项同义词搜索?请帮帮我〜
答案 0 :(得分:1)
以下是我处理多词同义词的方法。在我的schema.xml中,fieldType定义如下所示:
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizer="solr.KeywordTokenizerFactory"/>
<fieldType name="custom_text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- We will use synonyms only at index time to keep querying fast-->
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizer="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- We will use synonyms only at index time to keep querying fast
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
-->
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" />
</analyzer>
</fieldType>
需要注意的事项: