wahahajun / ik-analyzer

Automatically exported from code.google.com/p/ik-analyzer
0 stars 0 forks source link

solr 4.4.0 版本 修复useSmart! #125

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
重新实现了IKAnalyzerSolrFactory,大家可以用下!
package org.wltea.analyzer.lucene;

import java.io.Reader;
import java.util.Map;

import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.util.AttributeSource.AttributeFactory;

public class IKAnalyzerSolrFactory extends TokenizerFactory{

    private boolean useSmart;

    public boolean useSmart() {
        return useSmart;
    }

    public void setUseSmart(boolean useSmart) {
        this.useSmart = useSmart;
    }

     public IKAnalyzerSolrFactory(Map<String,String> args) {
         super(args);
         assureMatchVersion();
         this.setUseSmart(args.get("useSmart").toString().equals("true"));
       }

    @Override
    public Tokenizer create(AttributeFactory factory, Reader input) {
        Tokenizer _IKTokenizer = new IKTokenizer(input , this.useSmart);
        return _IKTokenizer;
    }

}

<fieldType name="text_ika" class="solr.TextField" >
        <analyzer type="index">
            <tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerSolrFactory" useSmart="false"/>
        </analyzer> 
        <analyzer type="query">
            <tokenizer class="org.wltea.analyzer.lucene.IKAnalyzerSolrFactory" useSmart="true"/>
        </analyzer> 
    </fieldType>

Original issue reported on code.google.com by lvlinz...@gmail.com on 13 Sep 2013 at 7:22

GoogleCodeExporter commented 8 years ago
Nice shot!

Original comment by homl...@gmail.com on 19 Nov 2013 at 8:44

GoogleCodeExporter commented 8 years ago
楼主看到回复能否留个Email,有问题请教。

Original comment by homl...@gmail.com on 20 Nov 2013 at 8:16

GoogleCodeExporter commented 8 years ago
好用,感谢!

Original comment by yangxiao...@gmail.com on 29 Nov 2013 at 2:34