lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Boyd <andrew.b...@mindspring.com>
Subject Highlighter ArrayIndexOutOfBoundsException - W/Fix
Date Wed, 01 Jun 2005 21:42:14 GMT
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


Mime
View raw message