Hi WeiWei, Thanks for the report.
Can you provide a self-contained unit test that triggers the bug? Thanks, Steve > -----Original Message----- > From: Weiwei Wang [mailto:ww.wang...@gmail.com] > Sent: Monday, May 23, 2011 1:25 AM > To: java-user@lucene.apache.org > Subject: FastVectorHighlighter StringIndexOutofBounds bug > > the following code has a bug of StringIndexOutofBounds when multiple > matched > terms need highlight > > private String makeFragment( WeightedFragInfo fragInfo, String src, int > s, > String[] preTags, String[] postTags, Encoder encoder ){ > StringBuilder fragment = new StringBuilder(); > int srcIndex = 0; > for( SubInfo subInfo : fragInfo.subInfos ){ > for( Toffs to : subInfo.termsOffsets ){ > fragment > .append( encoder.encodeText( src.substring( srcIndex, > to.startOffset - s ) ) ) > .append( getPreTag( preTags, subInfo.seqnum ) ) > .append( encoder.encodeText( src.substring( to.startOffset - s, > to.endOffset - s ) ) ) > .append( getPostTag( postTags, subInfo.seqnum ) ); > srcIndex = to.endOffset - s; > } > } > fragment.append( encoder.encodeText( src.substring( srcIndex ) ) ); > return fragment.toString(); > }-- > 王巍巍 > Cell: 18911288489 > MSN: ww.wang...@gmail.com > Blog: http://whisper.eyesay.org > 围脖:http://t.sina.com/lolorosa