The FAQ describes implementing a TokenFilter for applying aliases. I have a
trouble accomplishing this.
This is the code that I have so far for the next Method within AliasFilter.
After reading some posts, I also got the idea to call
setPositionIncrement(). Neither way works, because when I search for the
alias, no search results come back.
Thank you for your help,
Allen Atamer
----
public Token next() throws java.io.IOException {
Token token = tokenStream.next();
if (aliasMap == null || token == null) {
return token;
}
TermData t = (TermData)aliasMap.get(token.termText());
if (t == null) {
return token;
}
String tokenText = AliasManager.replaceIgnoreCase(
token.termText(), t.getTerm(), t.getTeach());
int increment = tokenText.length() - token.termText().length();
if (increment > 0) {
token.setPositionIncrement(increment);
}
return new Token(tokenText, token.startOffset(), token.endOffset());
}
|