mirror of https://github.com/apache/lucene.git
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:
parent
8934cbd804
commit
9d7babcb26
|
@ -148,6 +148,7 @@ public class FieldQuery {
|
||||||
* ex6) src="a b c", dest="b" => no overlap
|
* ex6) src="a b c", dest="b" => no overlap
|
||||||
* ex7) src="a a a a", dest="a a a" => overlap;
|
* ex7) src="a a a a", dest="a a a" => overlap;
|
||||||
* expandQueries={"a a a a a","a a a a a a"}
|
* 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 ){
|
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
|
// 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++ ){
|
for( int i = 1; i < src.length; i++ ){
|
||||||
boolean overlap = true;
|
boolean overlap = true;
|
||||||
for( int j = i; j < src.length; j++ ){
|
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;
|
overlap = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,13 @@ public class FieldQueryTest extends AbstractTestCase {
|
||||||
assertCollectionQueries( fq.expand( flatQueries ),
|
assertCollectionQueries( fq.expand( flatQueries ),
|
||||||
pqF( "a", "b", "c" ), pqF( "c", "d", "e" ), pqF( "a", "b", "c", "d", "e" ) );
|
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"
|
// "a b b","b c" => "a b b","b c","a b b c"
|
||||||
flatQueries = new HashSet<Query>();
|
flatQueries = new HashSet<Query>();
|
||||||
flatQueries.add( pqF( "a", "b", "b" ) );
|
flatQueries.add( pqF( "a", "b", "b" ) );
|
||||||
|
|
Loading…
Reference in New Issue