solr如何配置同时支持中文和英文的分词器?
我使用solr配置了三个字段,其中一个字段的类型为text general,此类型可以对中文进行分词,但是不对英文分词,那么如何配置一个类型,使其既支持中文分词又支持英文分词? text general字段类型的定义如下
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
小SusHi
11 years, 2 months ago
Answers
英文: https://cwiki.apache.org/confluence/display/solr/Filter+Descriptions#FilterDescriptions-NGramFilter 至于中文,默认就是字字分开,直接控制匹配度就行,要词分的话就用ik,但是TokenizerFactory要自己实现,不过写一下还是很方便的
bobgb
answered 11 years, 2 months ago