Hi,
yes, the easy way is sometimes the best way. In the end I am using now the
getAnalyzer() method to get the analyzer and use it to create a TokenStream:
Code:
TokenStream stream = analyzer.tokenStream(field, reader);
Anyhow, originally I wanted
QueryParser to automatically select the right analyzer for the specified field, which didn't work, because the
ScopedAnalyzer only contains instances of
PassThroughAnalyzer, when the
@Analyzer is defined on class/type level.
When fields are annotated with
@Analyzer, then instances of
DelegateNameAnalyzer are within the
ScopedAnalyzer and the
QueryParser uses the correct analyzer. This seems to me like a bug, because I would expect, that an class level analyzer is used on every field in its class.