How do I test the Lucene analyzer?
I am not getting the expected results from mine Analyzer
and would like to test the tokenization process.
The answer to this question is: How do I use Lucene Analyzer to tokenize a string?
List<String> result = new ArrayList<String>();
TokenStream stream = analyzer.tokenStream(field, new StringReader(keywords));
try {
while(stream.incrementToken()) {
result.add(stream.getAttribute(TermAttribute.class).term());
}
}
catch(IOException e) {
// not thrown b/c we're using a string reader...
}
return result;
Used TermAttribute
to extract tokens from a stream. The problem is that it is TermAttribute
no longer in Lucene 6.
What did he replace?
What would be the equivalent with Lucene 6.6.0?
+3
source to share
1 answer
I'm pretty sure it was replaced with CharTermAttribute
javadoc
The ticket is quite old, but the code may have been kept a little longer: https://issues.apache.org/jira/browse/LUCENE-2372
0
source to share