lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r816192 - in /lucene/java/trunk/contrib/fast-vector-highlighter/src: java/org/apache/lucene/search/vectorhighlight/FieldQuery.java test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java
Date Thu, 17 Sep 2009 13:56:51 GMT
Author: markrmiller
Date: Thu Sep 17 13:56:51 2009
New Revision: 816192

URL: http://svn.apache.org/viewvc?rev=816192&view=rev
Log:
LUCENE-1913: FastVectorHighlighter: AIOOBE occurs if one PhraseQuery is contained by another
PhraseQuery

Modified:
    lucene/java/trunk/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java
    lucene/java/trunk/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java

Modified: lucene/java/trunk/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java?rev=816192&r1=816191&r2=816192&view=diff
==============================================================================
--- lucene/java/trunk/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java
(original)
+++ lucene/java/trunk/contrib/fast-vector-highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java
Thu Sep 17 13:56:51 2009
@@ -148,6 +148,7 @@
    * 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 @@
     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;
         }

Modified: lucene/java/trunk/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java?rev=816192&r1=816191&r2=816192&view=diff
==============================================================================
--- lucene/java/trunk/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java
(original)
+++ lucene/java/trunk/contrib/fast-vector-highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java
Thu Sep 17 13:56:51 2009
@@ -94,6 +94,13 @@
     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" ) );



Mime
View raw message