Java 卢克+;lucene 5.4.1
我正在使用自定义分析器使用Lucene 5.4.1版本构建索引文件,并尝试使用Luke在索引文件中查找数据。我正在尝试将我的自定义分析器添加到Luke中,但在analyzers选项卡中找不到 我使用下面的语法将我的分析器添加到LukeJava-cp“pivot Luke with deps.jar;CatalogSearchAnalyzer.jar”org.getopt.Luke.Luke中 我的分析器代码`Java 卢克+;lucene 5.4.1,java,lucene,luke,Java,Lucene,Luke,我正在使用自定义分析器使用Lucene 5.4.1版本构建索引文件,并尝试使用Luke在索引文件中查找数据。我正在尝试将我的自定义分析器添加到Luke中,但在analyzers选项卡中找不到 我使用下面的语法将我的分析器添加到LukeJava-cp“pivot Luke with deps.jar;CatalogSearchAnalyzer.jar”org.getopt.Luke.Luke中 我的分析器代码` public class CatalogSearchAnalyzer extends
public class CatalogSearchAnalyzer extends Analyzer {
private Version matchVersion;
private String termValue;
private boolean retMultiple;
public static final String[] STOP_WORDS = { "a", "and", "are", "as", "at",
"be", "but", "by", "for", "if", "in", "into", "is", "it", "no",
"not", "of", "on", "or", "such", "t", "that", "the", "their",
"then", "there", "these", "they", "this", "to", "was", "will",
"with" };
private CharArraySet stopTable;
private int maxTokenLength;
public CatalogSearchAnalyzer(Version matchVersion) {
this.stopTable = StopFilter.makeStopSet(STOP_WORDS);
this.maxTokenLength = 255;
this.matchVersion = matchVersion;
}
public CatalogSearchAnalyzer() {
this(STOP_WORDS);
}
public void setTermValue(String termValue) {
}
public void setRetMultiple(boolean retMultiple) {
}
public CatalogSearchAnalyzer(String[] stopWords) {
this.stopTable = StopFilter.makeStopSet(STOP_WORDS);
this.maxTokenLength = 255;
StopFilter.makeStopSet(stopWords);
}
private TokenStream getStemmingFilter(TokenStream result) {
PorterStemFilter temp = new PorterStemFilter(result);
temp.setRetMultiple(this.retMultiple);
return temp;
}
protected Analyzer.TokenStreamComponents createComponents(String fieldName) {
StandardTokenizer st = new StandardTokenizer();
st.setMaxTokenLength(this.maxTokenLength);
Tokenizer tk = st;
TokenStream ts = new StandardFilter(tk);
ts = new LowerCaseFilter(ts);
ts = new StopFilter(ts, this.stopTable);
ts = getStemmingFilter(ts);
return new Analyzer.TokenStreamComponents(tk, ts) {
protected void setReader(Reader reader) {
int m = CatalogSearchAnalyzer.this.maxTokenLength;
if (this.source instanceof CmgtTokenizer) {
((CmgtTokenizer) this.source).setMaxTokenLength(m);
}
super.setReader(reader);
}
};
}
}
`
在将我的罐子添加到Luke时,我没有得到任何异常
提前感谢您对此进行研究。如问题下评论部分所述,解决方案是使用原始的基于thinlet的luke版本,而不是基于pivot的luke。基于pivot的luke正在开发中,尚未支持所有功能(尽管鼓励进行更多测试!) 大师级的Thinlet luke(目前):
Pivot luke on branch:尝试luke的非Pivot版本^。所以它可能缺少《大师》中的卢克(luke in master)(基于thinlet库)的特性(比如这一个)。