You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Andrew Boyd <an...@mindspring.com> on 2005/06/01 23:42:14 UTC
Highlighter ArrayIndexOutOfBoundsException - W/Fix
Hi,
I'm getting an ArrayIndexOutOfBoundsException within the highlighter:
java.lang.ArrayIndexOutOfBoundsException: 50
at org.apache.lucene.search.highlight.TokenGroup.addToken(TokenGroup.java:47)
at org.apache.lucene.search.highlight.Highlighter.getBestDocFragments(Highlighter.java:184)
at org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:101)
at org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:363)
It was working fine but I was having trouble getting highlights for phrases. I was advised to make sure
that I was using the same analyzer as when I indexed. I made that change and I'm now getting the exception.
The reason I'm getting the exception now, I'm sure, is that I have synonym capability in my application and when I use the synonym feature I exceed TokenGroup.MAX_NUM_TOKENS_PER_GROUP.
I've made a fix in my implementation. Here it is:
void addToken(Token token, float score)
{
if(numTokens < MAX_NUM_TOKENS_PER_GROUP) // new line
{
if(numTokens == 0){
startOffset = token.startOffset();
endOffset = token.endOffset();
} else{
startOffset = Math.min(startOffset, token.startOffset());
endOffset = Math.max(endOffset, token.endOffset());
}
tokens[numTokens] = token; // place where the exception was occuring.
scores[numTokens] = score;
numTokens++;
} // new line
}
Cheers,
Andrew
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org