add default config

This commit is contained in:
medcl 2014-09-11 11:08:11 +08:00
parent 0eaba078f9
commit ee419af6ea
2 changed files with 5 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import java.io.Reader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
@ -66,8 +67,8 @@ public final class IKAnalyzer extends Analyzer{
this.useSmart = useSmart;
}
Settings settings;
Environment environment;
Settings settings=ImmutableSettings.EMPTY;
Environment environment=new Environment();
public IKAnalyzer(Settings indexSetting,Settings settings, Environment environment) {
super();

View File

@ -49,7 +49,8 @@ public class IKAnalzyerDemo {
//获取Lucene的TokenStream对象
TokenStream ts = null;
try {
ts = analyzer.tokenStream("myfield", new StringReader("这是一个中文分词的例子你可以直接运行它IKAnalyer can analysis english text too"));
ts = analyzer.tokenStream("myfield", new StringReader("WORLD ,.. html DATA</html>HELLO"));
// ts = analyzer.tokenStream("myfield", new StringReader("这是一个中文分词的例子你可以直接运行它IKAnalyer can analysis english text too"));
//获取词元位置属性
OffsetAttribute offset = ts.addAttribute(OffsetAttribute.class);
//获取词元文本属性