LUCENE-1913: FastVectorHighlighter: AIOOBE occurs if one PhraseQuery is contained by another PhraseQuery

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@816192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2009-09-17 13:56:51 +00:00
parent 8934cbd804
commit 9d7babcb26
2 changed files with 9 additions and 1 deletions

View File

@ -148,6 +148,7 @@ public class FieldQuery {
* ex6) src="a b c", dest="b" => no overlap
* ex7) src="a a a a", dest="a a a" => overlap;
* expandQueries={"a a a a a","a a a a a a"}
* ex8) src="a b c d", dest="b c" => no overlap
*/
private void checkOverlap( Collection<Query> expandQueries, Term[] src, Term[] dest, int slop, float boost ){
// beginning from 1 (not 0) is safe because that the PhraseQuery has multiple terms
@ -156,7 +157,7 @@ public class FieldQuery {
for( int i = 1; i < src.length; i++ ){
boolean overlap = true;
for( int j = i; j < src.length; j++ ){
if( !src[j].text().equals( dest[j-i].text() ) ){
if( ( j - i ) < dest.length && !src[j].text().equals( dest[j-i].text() ) ){
overlap = false;
break;
}

View File

@ -94,6 +94,13 @@ public class FieldQueryTest extends AbstractTestCase {
assertCollectionQueries( fq.expand( flatQueries ),
pqF( "a", "b", "c" ), pqF( "c", "d", "e" ), pqF( "a", "b", "c", "d", "e" ) );
// "a b c d","b c" => "a b c d","b c"
flatQueries = new HashSet<Query>();
flatQueries.add( pqF( "a", "b", "c", "d" ) );
flatQueries.add( pqF( "b", "c" ) );
assertCollectionQueries( fq.expand( flatQueries ),
pqF( "a", "b", "c", "d" ), pqF( "b", "c" ) );
// "a b b","b c" => "a b b","b c","a b b c"
flatQueries = new HashSet<Query>();
flatQueries.add( pqF( "a", "b", "b" ) );