You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2013/02/26 23:15:08 UTC

svn commit: r1450483 - in /lucene/dev/branches/LUCENE-2878/lucene/core/src: java/org/apache/lucene/search/ java/org/apache/lucene/search/posfilter/ test/org/apache/lucene/search/posfilter/

Author: romseygeek
Date: Tue Feb 26 22:15:08 2013
New Revision: 1450483

URL: http://svn.apache.org/r1450483
Log:
Add sloppy phrase functionality; merge phrasequery and multiphrasequery; clean up tests

Added:
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PartiallyOrderedNearScorer.java   (with props)
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PhraseQuery2.java
      - copied, changed from r1449538, lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactPhraseQuery.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedPositionFilterQueries.java
      - copied, changed from r1447949, lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedIntervalFilterQueries.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestPhraseQuery2.java
      - copied, changed from r1449554, lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExactPhraseQuery.java
Removed:
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactMultiPhraseQuery.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactPhraseQuery.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestDisjunctionIntervalIterator.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExactPhraseQuery.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExoticQueries.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedIntervalFilterQueries.java
Modified:
    lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PositionQueue.java
    lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/IntervalTestBase.java

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PositionQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PositionQueue.java?rev=1450483&r1=1450482&r2=1450483&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PositionQueue.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/PositionQueue.java Tue Feb 26 22:15:08 2013
@@ -26,10 +26,12 @@ public class PositionQueue extends Prior
   public class DocsEnumRef {
 
     public final DocsEnum docsEnum;
+    public final int ord;
     public Interval interval = new Interval();
 
-    public DocsEnumRef(DocsEnum docsEnum) {
+    public DocsEnumRef(DocsEnum docsEnum, int ord) {
       this.docsEnum = docsEnum;
+      this.ord = ord;
     }
 
     public int nextPosition() throws IOException {
@@ -51,7 +53,7 @@ public class PositionQueue extends Prior
   public PositionQueue(DocsEnum... subDocsEnums) {
     super(subDocsEnums.length);
     for (int i = 0; i < subDocsEnums.length; i++) {
-      add(new DocsEnumRef(subDocsEnums[i]));
+      add(new DocsEnumRef(subDocsEnums[i], i));
     }
     queuesize = subDocsEnums.length;
   }

Added: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PartiallyOrderedNearScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PartiallyOrderedNearScorer.java?rev=1450483&view=auto
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PartiallyOrderedNearScorer.java (added)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PartiallyOrderedNearScorer.java Tue Feb 26 22:15:08 2013
@@ -0,0 +1,241 @@
+package org.apache.lucene.search.posfilter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.search.PositionQueue;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.util.SorterTemplate;
+
+import java.io.IOException;
+
+
+public class PartiallyOrderedNearScorer extends PositionFilteredScorer {
+
+  private final SloppySpanningPositionQueue posQueue;
+  private final int allowedSlop;
+
+  private int previousEnd;
+
+  public static int MAX_SLOP = Integer.MAX_VALUE;
+
+  public PartiallyOrderedNearScorer(Scorer filteredScorer, int allowedSlop) {
+    super(filteredScorer);
+    this.posQueue = new SloppySpanningPositionQueue(subScorers);
+    this.allowedSlop = allowedSlop;
+  }
+
+  @Override
+  protected int doNextPosition() throws IOException {
+    int currentSlop = MAX_SLOP;
+    while (posQueue.isFull() && posQueue.span.begin == current.begin) {
+      posQueue.nextPosition();
+    }
+    if (!posQueue.isFull())
+      return NO_MORE_POSITIONS;
+    while (true) {
+      do {
+        posQueue.updateCurrent(current);
+        currentSlop = posQueue.calculateSlop(allowedSlop);
+        if (current.equals(posQueue.top().interval) && currentSlop <= allowedSlop) {
+          previousEnd = current.end;
+          return current.begin;
+        }
+        posQueue.nextPosition();
+      } while (posQueue.isFull() && current.end == posQueue.span.end);
+      if (current.begin <= previousEnd)
+        continue;
+      if (currentSlop <= allowedSlop) {
+        previousEnd = current.end;
+        return current.begin;
+      }
+      if (!posQueue.isFull())
+        return NO_MORE_POSITIONS;
+    }
+  }
+
+  @Override
+  protected void reset(int doc) throws IOException {
+    super.reset(doc);
+    current.reset();
+    posQueue.advanceTo(doc);
+    previousEnd = -1;
+  }
+
+  private static class IntervalRef {
+
+    public Interval interval = new Interval();
+    public int ord;
+
+    public IntervalRef() {}
+
+    public void update(IntervalRef other) {
+      this.ord = other.ord;
+      this.interval.update(other.interval);
+    }
+
+    public void update(Interval interval, int ord) {
+      this.ord = ord;
+      this.interval.update(interval);
+    }
+  }
+
+  private static class SloppySpanningPositionQueue extends PositionQueue {
+
+    Interval span = new Interval();
+    final Interval[] subIntervals;
+    final IntervalRef[] sortedIntervals;
+    int scorerCount;
+
+    public SloppySpanningPositionQueue(Scorer[] subScorers) {
+      super(subScorers);
+      scorerCount = subScorers.length;
+      subIntervals = new Interval[subScorers.length];
+      sortedIntervals = new IntervalRef[subScorers.length];
+      for (int i = 0; i < subScorers.length; i++) {
+        subIntervals[i] = new Interval();
+        sortedIntervals[i] = new IntervalRef();
+      }
+    }
+
+    public boolean isFull() {
+      return queuesize == scorerCount;
+    }
+
+    public void updateCurrent(Interval current) {
+      final Interval top = this.top().interval;
+      current.update(top, span);
+    }
+
+    private void updateRightExtreme(Interval newRight) {
+      if (span.end <= newRight.end) {
+        span.update(span, newRight);
+      }
+    }
+
+    protected void updateInternalIntervals() {
+      DocsEnumRef deRef = top();
+      subIntervals[deRef.ord].update(deRef.interval);
+      //subIntervals[deRef.ord].ord = deRef.ord;
+      updateRightExtreme(deRef.interval);
+    }
+
+    @Override
+    public int nextPosition() throws IOException {
+      int position;
+      if ((position = super.nextPosition()) == DocsEnum.NO_MORE_POSITIONS) {
+        return DocsEnum.NO_MORE_POSITIONS;
+      }
+      span.update(top().interval, span);
+      return position;
+    }
+
+    @Override
+    protected void init() throws IOException {
+      super.init();
+      DocsEnumRef deRef;
+      for (Object heapRef : getHeapArray()) {
+        if (heapRef != null) {
+          deRef = (DocsEnumRef) heapRef;
+          subIntervals[deRef.ord].update(deRef.interval);
+          //subIntervals[deRef.ord].ord = deRef.ord;
+          updateRightExtreme(deRef.interval);
+        }
+      }
+    }
+
+    @Override
+    public void advanceTo(int doc) {
+      super.advanceTo(doc);
+      span.reset();
+    }
+
+    @Override
+    protected boolean lessThan(DocsEnumRef left, DocsEnumRef right) {
+      final Interval a = left.interval;
+      final Interval b = right.interval;
+      return a.begin < b.begin || (a.begin == b.begin && a.end > b.end);
+    }
+
+    @Override
+    public String toString() {
+      return top().interval.toString();
+    }
+
+    // nocommit, is this algorithm ok or is it going to be horribly inefficient?
+    // We sort the subintervals by their start positions.  If a subinterval is
+    // out of position, we calculate it's slop contribution by counting the
+    // number of subsequent subintervals with lower ords.  Gaps between subintervals
+    // are also added.  If the running total exceeds a provided max allowed slop,
+    // then we shortcut the calculation and return MAX_SLOP.
+    public int calculateSlop(int maxAllowedSlop) {
+      boolean swaps = false;
+      int slop = 0;
+      sortSubIntervals();
+      for (int i = 0; i < sortedIntervals.length; i++) {
+        if (swaps || sortedIntervals[i].ord != i) {
+          swaps = true;
+          for (int j = i + 1; j < sortedIntervals.length; j++) {
+            if (sortedIntervals[j].ord < sortedIntervals[i].ord)
+              slop++;
+          }
+        }
+        if (i > 0)
+          slop += (sortedIntervals[i].interval.begin - sortedIntervals[i - 1].interval.end) - 1;
+        if (slop > maxAllowedSlop)
+          return MAX_SLOP;
+      }
+      return slop;
+    }
+
+    private void sortSubIntervals() {
+
+      for (int i = 0; i < subIntervals.length; i++) {
+        sortedIntervals[i].update(subIntervals[i], i);
+      }
+
+      new SorterTemplate() {
+
+        int pivot;
+
+        @Override
+        protected void swap(int i, int j) {
+          IntervalRef temp = new IntervalRef();
+          temp.update(sortedIntervals[i]);
+          sortedIntervals[i].update(sortedIntervals[j]);
+          sortedIntervals[j].update(temp);
+        }
+
+        @Override
+        protected int compare(int i, int j) {
+          return Long.signum(sortedIntervals[i].interval.begin - sortedIntervals[j].interval.begin);
+        }
+
+        @Override
+        protected void setPivot(int i) {
+          this.pivot = sortedIntervals[i].interval.begin;
+        }
+
+        @Override
+        protected int comparePivot(int j) {
+          return Long.signum(pivot - sortedIntervals[j].interval.begin);
+        }
+      }.mergeSort(0, sortedIntervals.length - 1);
+    }
+  }
+}

Copied: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PhraseQuery2.java (from r1449538, lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactPhraseQuery.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PhraseQuery2.java?p2=lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PhraseQuery2.java&p1=lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactPhraseQuery.java&r1=1449538&r2=1450483&rev=1450483&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/ExactPhraseQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/posfilter/PhraseQuery2.java Tue Feb 26 22:15:08 2013
@@ -23,29 +23,56 @@ import org.apache.lucene.search.TermQuer
  * limitations under the License.
  */
 
-public class ExactPhraseQuery extends PositionFilterQuery {
+public class PhraseQuery2 extends PositionFilterQuery {
 
   private final BooleanQuery innerBQ;
+  private final int slop;
 
-  public ExactPhraseQuery() {
-    super(new BooleanQuery(), new ExactPhraseScorerFactory());
+  public PhraseQuery2(int slop) {
+    super(new BooleanQuery(), new ExactPhraseScorerFactory(slop));
     this.innerBQ = (BooleanQuery) innerQuery;
+    this.slop = slop;
+  }
+
+  public PhraseQuery2() {
+    this(0);
+  }
+
+  public int getSlop() {
+    return slop;
   }
 
   public void add(Term term) {
     innerBQ.add(new TermQuery(term), BooleanClause.Occur.MUST);
   }
 
+  public void addMultiTerm(Term... terms) {
+    BooleanQuery disj = new BooleanQuery();
+    for (Term term : terms) {
+      disj.add(new TermQuery(term), BooleanClause.Occur.SHOULD);
+    }
+    innerBQ.add(disj, BooleanClause.Occur.MUST);
+  }
+
   private static class ExactPhraseScorerFactory implements ScorerFilterFactory {
 
+    private final int slop;
+
+    ExactPhraseScorerFactory(int slop) {
+      this.slop = slop;
+    }
+
     @Override
     public Scorer scorer(Scorer filteredScorer) {
-      return new BlockPhraseScorer(filteredScorer);
+      if (slop == 0)
+        return new BlockPhraseScorer(filteredScorer);
+      else
+        return new PartiallyOrderedNearScorer(filteredScorer, slop);
     }
 
     @Override
     public String getName() {
-      return "ExactPhrase";
+      return slop == 0 ? "ExactPhrase" : "SloppyPhrase/" + slop;
     }
   }
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/IntervalTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/IntervalTestBase.java?rev=1450483&r1=1450482&r2=1450483&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/IntervalTestBase.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/IntervalTestBase.java Tue Feb 26 22:15:08 2013
@@ -1,5 +1,22 @@
 package org.apache.lucene.search.posfilter;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.index.IndexReader;
@@ -14,7 +31,6 @@ import org.apache.lucene.search.Position
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.search.posfilter.Interval;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.junit.After;
@@ -24,22 +40,6 @@ import org.junit.Before;
 import java.io.IOException;
 import java.util.Iterator;
 
-/**
- * Copyright (c) 2012 Lemur Consulting Ltd.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 public abstract class IntervalTestBase extends LuceneTestCase {
 
   protected Directory directory;

Copied: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedPositionFilterQueries.java (from r1447949, lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedIntervalFilterQueries.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedPositionFilterQueries.java?p2=lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedPositionFilterQueries.java&p1=lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedIntervalFilterQueries.java&r1=1447949&r2=1450483&rev=1450483&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedIntervalFilterQueries.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestNestedPositionFilterQueries.java Tue Feb 26 22:15:08 2013
@@ -23,12 +23,10 @@ import org.apache.lucene.index.RandomInd
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.posfilter.OrderedNearQuery;
-import org.apache.lucene.search.posfilter.UnorderedNearQuery;
 
 import java.io.IOException;
 
-public class TestNestedIntervalFilterQueries extends IntervalTestBase {
+public class TestNestedPositionFilterQueries extends IntervalTestBase {
 
   @Override
   protected void addDocs(RandomIndexWriter writer) throws IOException {

Copied: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestPhraseQuery2.java (from r1449554, lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExactPhraseQuery.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestPhraseQuery2.java?p2=lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestPhraseQuery2.java&p1=lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExactPhraseQuery.java&r1=1449554&r2=1450483&rev=1450483&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestExactPhraseQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/posfilter/TestPhraseQuery2.java Tue Feb 26 22:15:08 2013
@@ -22,7 +22,7 @@ import org.apache.lucene.index.Term;
 
 import java.io.IOException;
 
-public class TestExactPhraseQuery extends IntervalTestBase {
+public class TestPhraseQuery2 extends IntervalTestBase {
   
   protected void addDocs(RandomIndexWriter writer) throws IOException {
     {
@@ -54,12 +54,44 @@ public class TestExactPhraseQuery extend
     }
   }
 
+  public void testSloppyPhraseQuery() throws IOException {
+    PhraseQuery2 query = new PhraseQuery2(1);
+    query.add(new Term("field", "pease"));
+    query.add(new Term("field", "hot!"));
+    checkIntervals(query, searcher, new int[][]{
+        { 0, 0, 2, 31, 33 },
+        { 1, 3, 5, 34, 36 }
+    });
+  }
+
+  public void testManyTermSloppyPhraseQuery() throws IOException {
+    PhraseQuery2 query = new PhraseQuery2(2);
+    query.add(new Term("field", "pease"));
+    query.add(new Term("field", "porridge"));
+    query.add(new Term("field", "pot"));
+    checkIntervals(query, searcher, new int[][]{
+        { 0, 6, 10 },
+        { 1, 6, 10 }
+    });
+  }
+
+  public void testOutOfOrderSloppyPhraseQuery() throws IOException {
+    PhraseQuery2 query = new PhraseQuery2(1);
+    query.add(new Term("field", "pease"));
+    query.add(new Term("field", "cold!"));
+    query.add(new Term("field", "porridge"));
+    checkIntervals(query, searcher, new int[][]{
+        { 0, 3, 5, 34, 36 },
+        { 1, 0, 2, 31, 33 }
+    });
+  }
+
   public void testMultiPhrases() throws IOException {
 
-    ExactMultiPhraseQuery q = new ExactMultiPhraseQuery();
+    PhraseQuery2 q = new PhraseQuery2();
     q.add(new Term("field", "pease"));
     q.add(new Term("field", "porridge"));
-    q.add(new Term("field", "hot!"), new Term("field", "cold!"));
+    q.addMultiTerm(new Term("field", "hot!"), new Term("field", "cold!"));
 
     checkIntervals(q, searcher, new int[][]{
         { 0, 0, 2, 3, 5, 31, 33, 34, 36 },
@@ -68,7 +100,7 @@ public class TestExactPhraseQuery extend
   }
 
   public void testOverlaps() throws IOException {
-    ExactPhraseQuery q = new ExactPhraseQuery();
+    PhraseQuery2 q = new PhraseQuery2();
     q.add(new Term("field", "some"));
     q.add(new Term("field", "like"));
     q.add(new Term("field", "it"));
@@ -76,14 +108,14 @@ public class TestExactPhraseQuery extend
     q.add(new Term("field", "some"));
     q.add(new Term("field", "like"));
     checkIntervals(q, searcher, new int[][]{
-        { 0, 18, 23 },
-        { 1, 14, 19 }
+        {0, 18, 23},
+        {1, 14, 19}
     });
   }
 
   public void testMatching() throws IOException {
 
-    ExactPhraseQuery q = new ExactPhraseQuery();
+    PhraseQuery2 q = new PhraseQuery2();
     q.add(new Term("field", "pease"));
     q.add(new Term("field", "porridge"));
     q.add(new Term("field", "hot!"));
@@ -97,7 +129,7 @@ public class TestExactPhraseQuery extend
 
   public void testPartialMatching() throws IOException {
 
-    ExactPhraseQuery q = new ExactPhraseQuery();
+    PhraseQuery2 q = new PhraseQuery2();
     q.add(new Term("field", "pease"));
     q.add(new Term("field", "porridge"));
     q.add(new Term("field", "hot!"));
@@ -113,7 +145,7 @@ public class TestExactPhraseQuery extend
 
   public void testNonMatching() throws IOException {
 
-    ExactPhraseQuery q = new ExactPhraseQuery();
+    PhraseQuery2 q = new PhraseQuery2();
     q.add(new Term("field", "pease"));
     q.add(new Term("field", "hot!"));