Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solr 4.4.0 版本 修复useSmart! #125

Open
GoogleCodeExporter opened this issue Apr 7, 2016 · 3 comments
Open

solr 4.4.0 版本 修复useSmart! #125

GoogleCodeExporter opened this issue Apr 7, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

重新实现了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 [email protected] on 13 Sep 2013 at 7:22

@GoogleCodeExporter
Copy link
Author

Nice shot!

Original comment by [email protected] on 19 Nov 2013 at 8:44

@GoogleCodeExporter
Copy link
Author

楼主看到回复能否留个Email,有问题请教。

Original comment by [email protected] on 20 Nov 2013 at 8:16

@GoogleCodeExporter
Copy link
Author

好用,感谢!

Original comment by [email protected] on 29 Nov 2013 at 2:34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant