ik拡張サポートSolr構成
1693 ワード
拡張ik原生コード:public class IK AnalyzerTokenizerFactory extends TokenizerFactory{private boolean useSmart;
public boolean useSmart() { return this.useSmart; }
public void setUseSmart(boolean useSmart) { this.useSmart = useSmart; }
public IKAnalyzerTokenizerFactory(Map args) { super(args); assureMatchVersion(); setUseSmart(((String)args.get("useSmart")).toString().equals("true")); }
public Tokenizer create(AttributeSource.AttributeFactory factory, Reader input) { Tokenizer _IKTokenizer = new IKTokenizer(input, this.useSmart); return _IKTokenizer; }}
ikを再パッケージし、solrの構成情報は以下の通りです.
public boolean useSmart() { return this.useSmart; }
public void setUseSmart(boolean useSmart) { this.useSmart = useSmart; }
public IKAnalyzerTokenizerFactory(Map
public Tokenizer create(AttributeSource.AttributeFactory factory, Reader input) { Tokenizer _IKTokenizer = new IKTokenizer(input, this.useSmart); return _IKTokenizer; }}
ikを再パッケージし、solrの構成情報は以下の通りです.
<fieldType name="text_ik" class="solr.TextField">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerTokenizerFactory" useSmart="false"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerTokenizerFactory" useSmart="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
</analyzer>
</fieldType>