You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/02/23 23:04:07 UTC
[2/2] lucene-solr git commit: LUCENE-7045: remove all encode/decode
hooks from PointRangeQuery
LUCENE-7045: remove all encode/decode hooks from PointRangeQuery
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/099e0311
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/099e0311
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/099e0311
Branch: refs/heads/master
Commit: 099e0311398cb61f53a1b58ed567053bec4904aa
Parents: 18bb8ca
Author: Robert Muir <rm...@apache.org>
Authored: Tue Feb 23 17:03:19 2016 -0500
Committer: Robert Muir <rm...@apache.org>
Committed: Tue Feb 23 17:03:55 2016 -0500
----------------------------------------------------------------------
.../org/apache/lucene/document/BinaryPoint.java | 101 ++++-
.../org/apache/lucene/document/DoublePoint.java | 99 ++++-
.../org/apache/lucene/document/FloatPoint.java | 99 ++++-
.../org/apache/lucene/document/IntPoint.java | 97 ++++-
.../org/apache/lucene/document/LongPoint.java | 101 ++++-
.../apache/lucene/search/PointRangeQuery.java | 402 ++-----------------
.../index/TestDemoParallelLeafReader.java | 3 +-
.../apache/lucene/search/TestPointQueries.java | 104 ++---
.../TestUsageTrackingFilterCachingPolicy.java | 4 +-
.../demo/facet/DistanceFacetsExample.java | 10 +-
.../lucene/demo/facet/RangeFacetsExample.java | 4 +-
.../facet/range/TestRangeFacetCounts.java | 21 +-
.../search/highlight/HighlighterTest.java | 3 +-
.../apache/lucene/document/BigIntegerPoint.java | 56 +--
.../lucene/document/InetAddressPoint.java | 64 +--
.../lucene/document/TestBigIntegerPoint.java | 8 +-
.../lucene/document/TestInetAddressPoint.java | 20 +-
.../lucene/search/TestDocValuesRangeQuery.java | 9 +-
.../suggest/document/TestSuggestField.java | 3 +-
.../lucene/index/BasePointFormatTestCase.java | 5 +-
20 files changed, 638 insertions(+), 575 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/document/BinaryPoint.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/BinaryPoint.java b/lucene/core/src/java/org/apache/lucene/document/BinaryPoint.java
index f80e1c0..8dd3925 100644
--- a/lucene/core/src/java/org/apache/lucene/document/BinaryPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/BinaryPoint.java
@@ -16,14 +16,22 @@
*/
package org.apache.lucene.document;
-
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.util.BytesRef;
-/** A binary field that is indexed dimensionally such that finding
- * all documents within an N-dimensional shape or range at search time is
- * efficient. Multiple values for the same field in one documents
- * is allowed. */
-
+/**
+ * A binary field that is indexed dimensionally such that finding
+ * all documents within an N-dimensional shape or range at search time is
+ * efficient. Multiple values for the same field in one documents
+ * is allowed.
+ * <p>
+ * This field defines static factory methods for creating common queries:
+ * <ul>
+ * <li>{@link #newExactQuery newExactQuery()} for matching an exact 1D point.
+ * <li>{@link #newRangeQuery newRangeQuery()} for matching a 1D range.
+ * <li>{@link #newMultiRangeQuery newMultiRangeQuery()} for matching points/ranges in n-dimensional space.
+ * </ul>
+ */
public final class BinaryPoint extends Field {
private static FieldType getType(byte[][] point) {
@@ -107,4 +115,85 @@ public final class BinaryPoint extends Field {
throw new IllegalArgumentException("packedPoint is length=" + packedPoint.length + " but type.pointDimensionCount()=" + type.pointDimensionCount() + " and type.pointNumBytes()=" + type.pointNumBytes());
}
}
+
+ // static methods for generating queries
+
+ /**
+ * Create a query for matching an exact binary value.
+ * <p>
+ * This is for simple one-dimension points, for multidimensional points use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param value binary value
+ * @throws IllegalArgumentException if {@code field} is null or {@code value} is null
+ * @return a query matching documents with this exact value
+ */
+ public static PointRangeQuery newExactQuery(String field, byte[] value) {
+ if (value == null) {
+ throw new IllegalArgumentException("value cannot be null");
+ }
+ return newRangeQuery(field, value, true, value, true);
+ }
+
+ /**
+ * Create a range query for binary values.
+ * <p>
+ * This is for simple one-dimension ranges, for multidimensional ranges use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
+ * <p>
+ * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} means "open".
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} means "open".
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newRangeQuery(String field, byte[] lowerValue, boolean lowerInclusive, byte[] upperValue, boolean upperInclusive) {
+ return newMultiRangeQuery(field, new byte[][] {lowerValue}, new boolean[] {lowerInclusive}, new byte[][] {upperValue}, new boolean[] {upperInclusive});
+ }
+
+ /**
+ * Create a multidimensional range query for binary values.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
+ * <p>
+ * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newMultiRangeQuery(String field, byte[][] lowerValue, boolean[] lowerInclusive, byte[][] upperValue, boolean[] upperInclusive) {
+ PointRangeQuery.checkArgs(field, lowerValue, upperValue);
+ return new PointRangeQuery(field, lowerValue, lowerInclusive, upperValue, upperInclusive) {
+ @Override
+ protected String toString(byte[] value) {
+ assert value != null;
+ StringBuilder sb = new StringBuilder();
+ sb.append("binary(");
+ for (int i = 0; i < value.length; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ sb.append(Integer.toHexString(value[i] & 0xFF));
+ }
+ sb.append(')');
+ return sb.toString();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java b/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
index e21c639..ee0d6f2 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
@@ -16,14 +16,23 @@
*/
package org.apache.lucene.document;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
-/** A double field that is indexed dimensionally such that finding
- * all documents within an N-dimensional shape or range at search time is
- * efficient. Multiple values for the same field in one documents
- * is allowed. */
-
+/**
+ * A double field that is indexed dimensionally such that finding
+ * all documents within an N-dimensional shape or range at search time is
+ * efficient. Multiple values for the same field in one documents
+ * is allowed.
+ * <p>
+ * This field defines static factory methods for creating common queries:
+ * <ul>
+ * <li>{@link #newExactQuery newExactQuery()} for matching an exact 1D point.
+ * <li>{@link #newRangeQuery newRangeQuery()} for matching a 1D range.
+ * <li>{@link #newMultiRangeQuery newMultiRangeQuery()} for matching points/ranges in n-dimensional space.
+ * </ul>
+ */
public final class DoublePoint extends Field {
private static FieldType getType(int numDims) {
@@ -78,7 +87,7 @@ public final class DoublePoint extends Field {
}
/** Creates a new DoublePoint, indexing the
- * provided N-dimensional int point.
+ * provided N-dimensional double point.
*
* @param name field name
* @param point double[] value
@@ -108,10 +117,8 @@ public final class DoublePoint extends Field {
return result.toString();
}
- // public helper methods (e.g. for queries)
-
/** Encode n-dimensional double point into binary encoding */
- public static byte[][] encode(Double value[]) {
+ private static byte[][] encode(Double value[]) {
byte[][] encoded = new byte[value.length][];
for (int i = 0; i < value.length; i++) {
if (value[i] != null) {
@@ -122,6 +129,8 @@ public final class DoublePoint extends Field {
return encoded;
}
+ // public helper methods (e.g. for queries)
+
/** Encode single double dimension */
public static void encodeDimension(Double value, byte dest[], int offset) {
NumericUtils.longToBytesDirect(NumericUtils.doubleToSortableLong(value), dest, offset);
@@ -131,4 +140,76 @@ public final class DoublePoint extends Field {
public static Double decodeDimension(byte value[], int offset) {
return NumericUtils.sortableLongToDouble(NumericUtils.bytesToLongDirect(value, offset));
}
+
+ // static methods for generating queries
+
+ /**
+ * Create a query for matching an exact double value.
+ * <p>
+ * This is for simple one-dimension points, for multidimensional points use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param value double value
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents with this exact value
+ */
+ public static PointRangeQuery newExactQuery(String field, double value) {
+ return newRangeQuery(field, value, true, value, true);
+ }
+
+ /**
+ * Create a range query for double values.
+ * <p>
+ * This is for simple one-dimension ranges, for multidimensional ranges use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
+ * <p>
+ * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} means "open".
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} means "open".
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newRangeQuery(String field, Double lowerValue, boolean lowerInclusive, Double upperValue, boolean upperInclusive) {
+ return newMultiRangeQuery(field,
+ new Double[] { lowerValue },
+ new boolean[] { lowerInclusive },
+ new Double[] { upperValue },
+ new boolean[] { upperInclusive });
+ }
+
+ /**
+ * Create a multidimensional range query for double values.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
+ * <p>
+ * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newMultiRangeQuery(String field, Double[] lowerValue, boolean lowerInclusive[], Double[] upperValue, boolean upperInclusive[]) {
+ PointRangeQuery.checkArgs(field, lowerValue, upperValue);
+ return new PointRangeQuery(field, DoublePoint.encode(lowerValue), lowerInclusive, DoublePoint.encode(upperValue), upperInclusive) {
+ @Override
+ protected String toString(byte[] value) {
+ return DoublePoint.decodeDimension(value, 0).toString();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java b/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
index c511603..34216b4 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
@@ -16,14 +16,23 @@
*/
package org.apache.lucene.document;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
-/** A field that is indexed dimensionally such that finding
- * all documents within an N-dimensional at search time is
- * efficient. Multiple values for the same field in one documents
- * is allowed. */
-
+/**
+ * A float field that is indexed dimensionally such that finding
+ * all documents within an N-dimensional at search time is
+ * efficient. Multiple values for the same field in one documents
+ * is allowed.
+ * <p>
+ * This field defines static factory methods for creating common queries:
+ * <ul>
+ * <li>{@link #newExactQuery newExactQuery()} for matching an exact 1D point.
+ * <li>{@link #newRangeQuery newRangeQuery()} for matching a 1D range.
+ * <li>{@link #newMultiRangeQuery newMultiRangeQuery()} for matching points/ranges in n-dimensional space.
+ * </ul>
+ */
public final class FloatPoint extends Field {
private static FieldType getType(int numDims) {
@@ -81,7 +90,7 @@ public final class FloatPoint extends Field {
* provided N-dimensional float point.
*
* @param name field name
- * @param point int[] value
+ * @param point float[] value
* @throws IllegalArgumentException if the field name or value is null.
*/
public FloatPoint(String name, float... point) {
@@ -108,10 +117,8 @@ public final class FloatPoint extends Field {
return result.toString();
}
- // public helper methods (e.g. for queries)
-
/** Encode n-dimensional float values into binary encoding */
- public static byte[][] encode(Float value[]) {
+ private static byte[][] encode(Float value[]) {
byte[][] encoded = new byte[value.length][];
for (int i = 0; i < value.length; i++) {
if (value[i] != null) {
@@ -122,6 +129,8 @@ public final class FloatPoint extends Field {
return encoded;
}
+ // public helper methods (e.g. for queries)
+
/** Encode single float dimension */
public static void encodeDimension(Float value, byte dest[], int offset) {
NumericUtils.intToBytesDirect(NumericUtils.floatToSortableInt(value), dest, offset);
@@ -131,4 +140,76 @@ public final class FloatPoint extends Field {
public static Float decodeDimension(byte value[], int offset) {
return NumericUtils.sortableIntToFloat(NumericUtils.bytesToIntDirect(value, offset));
}
+
+ // static methods for generating queries
+
+ /**
+ * Create a query for matching an exact float value.
+ * <p>
+ * This is for simple one-dimension points, for multidimensional points use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param value float value
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents with this exact value
+ */
+ public static PointRangeQuery newExactQuery(String field, float value) {
+ return newRangeQuery(field, value, true, value, true);
+ }
+
+ /**
+ * Create a range query for float values.
+ * <p>
+ * This is for simple one-dimension ranges, for multidimensional ranges use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
+ * <p>
+ * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} means "open".
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} means "open".
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newRangeQuery(String field, Float lowerValue, boolean lowerInclusive, Float upperValue, boolean upperInclusive) {
+ return newMultiRangeQuery(field,
+ new Float[] { lowerValue },
+ new boolean[] { lowerInclusive },
+ new Float[] { upperValue },
+ new boolean[] { upperInclusive });
+ }
+
+ /**
+ * Create a multidimensional range query for float values.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
+ * <p>
+ * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newMultiRangeQuery(String field, Float[] lowerValue, boolean lowerInclusive[], Float[] upperValue, boolean upperInclusive[]) {
+ PointRangeQuery.checkArgs(field, lowerValue, upperValue);
+ return new PointRangeQuery(field, FloatPoint.encode(lowerValue), lowerInclusive, FloatPoint.encode(upperValue), upperInclusive) {
+ @Override
+ protected String toString(byte[] value) {
+ return FloatPoint.decodeDimension(value, 0).toString();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/IntPoint.java b/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
index be91bfd..177ae99 100644
--- a/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
@@ -16,14 +16,23 @@
*/
package org.apache.lucene.document;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
-/** An int field that is indexed dimensionally such that finding
- * all documents within an N-dimensional shape or range at search time is
- * efficient. Multiple values for the same field in one documents
- * is allowed. */
-
+/**
+ * An int field that is indexed dimensionally such that finding
+ * all documents within an N-dimensional shape or range at search time is
+ * efficient. Multiple values for the same field in one documents
+ * is allowed.
+ * <p>
+ * This field defines static factory methods for creating common queries:
+ * <ul>
+ * <li>{@link #newExactQuery newExactQuery()} for matching an exact 1D point.
+ * <li>{@link #newRangeQuery newRangeQuery()} for matching a 1D range.
+ * <li>{@link #newMultiRangeQuery newMultiRangeQuery()} for matching points/ranges in n-dimensional space.
+ * </ul>
+ */
public final class IntPoint extends Field {
private static FieldType getType(int numDims) {
@@ -108,10 +117,8 @@ public final class IntPoint extends Field {
return result.toString();
}
- // public helper methods (e.g. for queries)
-
/** Encode n-dimensional integer values into binary encoding */
- public static byte[][] encode(Integer value[]) {
+ private static byte[][] encode(Integer value[]) {
byte[][] encoded = new byte[value.length][];
for (int i = 0; i < value.length; i++) {
if (value[i] != null) {
@@ -122,6 +129,8 @@ public final class IntPoint extends Field {
return encoded;
}
+ // public helper methods (e.g. for queries)
+
/** Encode single integer dimension */
public static void encodeDimension(Integer value, byte dest[], int offset) {
NumericUtils.intToBytes(value, dest, offset);
@@ -131,4 +140,76 @@ public final class IntPoint extends Field {
public static Integer decodeDimension(byte value[], int offset) {
return NumericUtils.bytesToInt(value, offset);
}
+
+ // static methods for generating queries
+
+ /**
+ * Create a query for matching an exact integer value.
+ * <p>
+ * This is for simple one-dimension points, for multidimensional points use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param value exact value
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents with this exact value
+ */
+ public static PointRangeQuery newExactQuery(String field, int value) {
+ return newRangeQuery(field, value, true, value, true);
+ }
+
+ /**
+ * Create a range query for integer values.
+ * <p>
+ * This is for simple one-dimension ranges, for multidimensional ranges use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
+ * <p>
+ * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} means "open".
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} means "open".
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newRangeQuery(String field, Integer lowerValue, boolean lowerInclusive, Integer upperValue, boolean upperInclusive) {
+ return newMultiRangeQuery(field,
+ new Integer[] { lowerValue },
+ new boolean[] { lowerInclusive },
+ new Integer[] { upperValue },
+ new boolean[] { upperInclusive });
+ }
+
+ /**
+ * Create a multidimensional range query for integer values.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
+ * <p>
+ * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newMultiRangeQuery(String field, Integer[] lowerValue, boolean lowerInclusive[], Integer[] upperValue, boolean upperInclusive[]) {
+ PointRangeQuery.checkArgs(field, lowerValue, upperValue);
+ return new PointRangeQuery(field, IntPoint.encode(lowerValue), lowerInclusive, IntPoint.encode(upperValue), upperInclusive) {
+ @Override
+ protected String toString(byte[] value) {
+ return IntPoint.decodeDimension(value, 0).toString();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/LongPoint.java b/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
index 38ff720..d3f8c17 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
@@ -16,14 +16,23 @@
*/
package org.apache.lucene.document;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
-/** A long field that is indexed dimensionally such that finding
- * all documents within an N-dimensional shape or range at search time is
- * efficient. Multiple values for the same field in one documents
- * is allowed. */
-
+/**
+ * A long field that is indexed dimensionally such that finding
+ * all documents within an N-dimensional shape or range at search time is
+ * efficient. Multiple values for the same field in one documents
+ * is allowed.
+ * <p>
+ * This field defines static factory methods for creating common queries:
+ * <ul>
+ * <li>{@link #newExactQuery newExactQuery()} for matching an exact 1D point.
+ * <li>{@link #newRangeQuery newRangeQuery()} for matching a 1D range.
+ * <li>{@link #newMultiRangeQuery newMultiRangeQuery()} for matching points/ranges in n-dimensional space.
+ * </ul>
+ */
public final class LongPoint extends Field {
private static FieldType getType(int numDims) {
@@ -78,10 +87,10 @@ public final class LongPoint extends Field {
}
/** Creates a new LongPoint, indexing the
- * provided N-dimensional int point.
+ * provided N-dimensional long point.
*
* @param name field name
- * @param point int[] value
+ * @param point long[] value
* @throws IllegalArgumentException if the field name or value is null.
*/
public LongPoint(String name, long... point) {
@@ -108,10 +117,8 @@ public final class LongPoint extends Field {
return result.toString();
}
- // public helper methods (e.g. for queries)
-
/** Encode n-dimensional long values into binary encoding */
- public static byte[][] encode(Long value[]) {
+ private static byte[][] encode(Long value[]) {
byte[][] encoded = new byte[value.length][];
for (int i = 0; i < value.length; i++) {
if (value[i] != null) {
@@ -122,6 +129,8 @@ public final class LongPoint extends Field {
return encoded;
}
+ // public helper methods (e.g. for queries)
+
/** Encode single long dimension */
public static void encodeDimension(Long value, byte dest[], int offset) {
NumericUtils.longToBytes(value, dest, offset);
@@ -131,4 +140,76 @@ public final class LongPoint extends Field {
public static Long decodeDimension(byte value[], int offset) {
return NumericUtils.bytesToLong(value, offset);
}
+
+ // static methods for generating queries
+
+ /**
+ * Create a query for matching an exact long value.
+ * <p>
+ * This is for simple one-dimension points, for multidimensional points use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param value exact value
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents with this exact value
+ */
+ public static PointRangeQuery newExactQuery(String field, long value) {
+ return newRangeQuery(field, value, true, value, true);
+ }
+
+ /**
+ * Create a range query for long values.
+ * <p>
+ * This is for simple one-dimension ranges, for multidimensional ranges use
+ * {@link #newMultiRangeQuery newMultiRangeQuery()} instead.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
+ * <p>
+ * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} means "open".
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} means "open".
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null.
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newRangeQuery(String field, Long lowerValue, boolean lowerInclusive, Long upperValue, boolean upperInclusive) {
+ return newMultiRangeQuery(field,
+ new Long[] { lowerValue },
+ new boolean[] { lowerInclusive },
+ new Long[] { upperValue },
+ new boolean[] { upperInclusive });
+ }
+
+ /**
+ * Create a multidimensional range query for long values.
+ * <p>
+ * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
+ * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
+ * <p>
+ * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
+ * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+ *
+ * @param field field name. must not be {@code null}.
+ * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
+ * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
+ * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
+ * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
+ * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
+ * @return a query matching documents within this range.
+ */
+ public static PointRangeQuery newMultiRangeQuery(String field, Long[] lowerValue, boolean lowerInclusive[], Long[] upperValue, boolean upperInclusive[]) {
+ PointRangeQuery.checkArgs(field, lowerValue, upperValue);
+ return new PointRangeQuery(field, LongPoint.encode(lowerValue), lowerInclusive, LongPoint.encode(upperValue), upperInclusive) {
+ @Override
+ protected String toString(byte[] value) {
+ return LongPoint.decodeDimension(value, 0).toString();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
index bf2b2ef..9db80fc 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -24,11 +24,11 @@ import java.util.Objects;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation;
-import org.apache.lucene.document.BinaryPoint;
-import org.apache.lucene.document.DoublePoint;
-import org.apache.lucene.document.FloatPoint;
-import org.apache.lucene.document.IntPoint;
-import org.apache.lucene.document.LongPoint;
+import org.apache.lucene.document.BinaryPoint; // javadocs
+import org.apache.lucene.document.DoublePoint; // javadocs
+import org.apache.lucene.document.FloatPoint; // javadocs
+import org.apache.lucene.document.IntPoint; // javadocs
+import org.apache.lucene.document.LongPoint; // javadocs
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -36,11 +36,23 @@ import org.apache.lucene.util.DocIdSetBuilder;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.StringHelper;
-/** Searches for ranges in fields previously indexed using points e.g.
- * {@link org.apache.lucene.document.LongPoint}. In a 1D field this is
- * a simple range query; in a multi-dimensional field it's a box shape. */
-// TODO: enhance this and add simple example
-public class PointRangeQuery extends Query {
+/**
+ * Abstract class for range queries against single or multidimensional points such as
+ * {@link IntPoint}.
+ * <p>
+ * This is for subclasses and works on the underlying binary encoding: to
+ * create range queries for lucene's standard {@code Point} types, refer to factory
+ * methods on those classes, e.g. {@link IntPoint#newRangeQuery IntPoint.newRangeQuery()} for
+ * fields indexed with {@link IntPoint}.
+ * <p>
+ * For a single-dimensional field this query is a simple range query; in a multi-dimensional field it's a box shape.
+ * @see IntPoint
+ * @see LongPoint
+ * @see FloatPoint
+ * @see DoublePoint
+ * @see BinaryPoint
+ */
+public abstract class PointRangeQuery extends Query {
final String field;
final int numDims;
final byte[][] lowerPoint;
@@ -53,16 +65,6 @@ public class PointRangeQuery extends Query {
/**
* Expert: create a multidimensional range query for point values.
* <p>
- * This is for subclasses and works on the underlying binary encoding: to
- * create range queries for lucene's standard {@code Point} types, refer to these factory methods:
- * <ul>
- * <li>{@link #newIntRange newIntRange()}/{@link #newMultiIntRange newMultiIntRange()} for fields indexed with {@link IntPoint}
- * <li>{@link #newIntRange newLongRange()}/{@link #newMultiIntRange newMultiLongRange()} for fields indexed with {@link LongPoint}
- * <li>{@link #newIntRange newFloatRange()}/{@link #newMultiIntRange newMultiFloatRange()} for fields indexed with {@link FloatPoint}
- * <li>{@link #newIntRange newDoubleRange()}/{@link #newMultiIntRange newMultiDoubleRange()} for fields indexed with {@link DoublePoint}
- * <li>{@link #newIntRange newBinaryRange()}/{@link #newMultiIntRange newMultiBinaryRange()} for fields indexed with {@link BinaryPoint}
- * </ul>
- * <p>
* You can have half-open ranges (which are in fact </≤ or >/≥ queries)
* by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
* <p>
@@ -132,350 +134,6 @@ public class PointRangeQuery extends Query {
}
}
- /**
- * Create a range query for matching an exact integer value.
- * <p>
- * This is for simple one-dimension points, for multidimensional points use
- * {@link #newMultiIntRange newMultiIntRange()} instead.
- *
- * @param field field name. must not be {@code null}.
- * @param value exact value
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents with this exact value
- */
- public static PointRangeQuery newIntExact(String field, int value) {
- return newIntRange(field, value, true, value, true);
- }
-
- /**
- * Create a range query for integer values indexed with {@link IntPoint}.
- * <p>
- * This is for simple one-dimension ranges, for multidimensional ranges use
- * {@link #newMultiIntRange newMultiIntRange()} instead.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
- * <p>
- * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} means "open".
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} means "open".
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newIntRange(String field, Integer lowerValue, boolean lowerInclusive, Integer upperValue, boolean upperInclusive) {
- return newMultiIntRange(field,
- new Integer[] { lowerValue },
- new boolean[] { lowerInclusive },
- new Integer[] { upperValue },
- new boolean[] { upperInclusive });
- }
-
- /**
- * Create a multidimensional range query for integer values indexed with {@link IntPoint}.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
- * <p>
- * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newMultiIntRange(String field, Integer[] lowerValue, boolean lowerInclusive[], Integer[] upperValue, boolean upperInclusive[]) {
- checkArgs(field, lowerValue, upperValue);
- return new PointRangeQuery(field, IntPoint.encode(lowerValue), lowerInclusive, IntPoint.encode(upperValue), upperInclusive) {
- @Override
- protected String toString(byte[] value) {
- return IntPoint.decodeDimension(value, 0).toString();
- }
- };
- }
-
- /**
- * Create a range query for matching an exact long value.
- * <p>
- * This is for simple one-dimension points, for multidimensional points use
- * {@link #newMultiLongRange newMultiLongRange()} instead.
- *
- * @param field field name. must not be {@code null}.
- * @param value exact value
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents with this exact value
- */
- public static PointRangeQuery newLongExact(String field, long value) {
- return newLongRange(field, value, true, value, true);
- }
-
- /**
- * Create a range query for long values indexed with {@link LongPoint}.
- * <p>
- * This is for simple one-dimension ranges, for multidimensional ranges use
- * {@link #newMultiLongRange newMultiLongRange()} instead.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
- * <p>
- * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} means "open".
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} means "open".
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newLongRange(String field, Long lowerValue, boolean lowerInclusive, Long upperValue, boolean upperInclusive) {
- return newMultiLongRange(field,
- new Long[] { lowerValue },
- new boolean[] { lowerInclusive },
- new Long[] { upperValue },
- new boolean[] { upperInclusive });
- }
-
- /**
- * Create a multidimensional range query for long values indexed with {@link LongPoint}.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
- * <p>
- * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newMultiLongRange(String field, Long[] lowerValue, boolean lowerInclusive[], Long[] upperValue, boolean upperInclusive[]) {
- checkArgs(field, lowerValue, upperValue);
- return new PointRangeQuery(field, LongPoint.encode(lowerValue), lowerInclusive, LongPoint.encode(upperValue), upperInclusive) {
- @Override
- protected String toString(byte[] value) {
- return LongPoint.decodeDimension(value, 0).toString();
- }
- };
- }
-
- /**
- * Create a range query for matching an exact float value.
- * <p>
- * This is for simple one-dimension points, for multidimensional points use
- * {@link #newMultiFloatRange newMultiFloatRange()} instead.
- *
- * @param field field name. must not be {@code null}.
- * @param value float value
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents with this exact value
- */
- public static PointRangeQuery newFloatExact(String field, float value) {
- return newFloatRange(field, value, true, value, true);
- }
-
- /**
- * Create a range query for float values indexed with {@link FloatPoint}.
- * <p>
- * This is for simple one-dimension ranges, for multidimensional ranges use
- * {@link #newMultiFloatRange newMultiFloatRange()} instead.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
- * <p>
- * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} means "open".
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} means "open".
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newFloatRange(String field, Float lowerValue, boolean lowerInclusive, Float upperValue, boolean upperInclusive) {
- return newMultiFloatRange(field,
- new Float[] { lowerValue },
- new boolean[] { lowerInclusive },
- new Float[] { upperValue },
- new boolean[] { upperInclusive });
- }
-
- /**
- * Create a multidimensional range query for float values indexed with {@link FloatPoint}.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
- * <p>
- * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newMultiFloatRange(String field, Float[] lowerValue, boolean lowerInclusive[], Float[] upperValue, boolean upperInclusive[]) {
- checkArgs(field, lowerValue, upperValue);
- return new PointRangeQuery(field, FloatPoint.encode(lowerValue), lowerInclusive, FloatPoint.encode(upperValue), upperInclusive) {
- @Override
- protected String toString(byte[] value) {
- return FloatPoint.decodeDimension(value, 0).toString();
- }
- };
- }
-
- /**
- * Create a range query for matching an exact double value.
- * <p>
- * This is for simple one-dimension points, for multidimensional points use
- * {@link #newMultiDoubleRange newMultiDoubleRange()} instead.
- *
- * @param field field name. must not be {@code null}.
- * @param value double value
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents with this exact value
- */
- public static PointRangeQuery newDoubleExact(String field, double value) {
- return newDoubleRange(field, value, true, value, true);
- }
-
- /**
- * Create a range query for double values indexed with {@link DoublePoint}.
- * <p>
- * This is for simple one-dimension ranges, for multidimensional ranges use
- * {@link #newMultiDoubleRange newMultiDoubleRange()} instead.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
- * <p>
- * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} means "open".
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} means "open".
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newDoubleRange(String field, Double lowerValue, boolean lowerInclusive, Double upperValue, boolean upperInclusive) {
- return newMultiDoubleRange(field,
- new Double[] { lowerValue },
- new boolean[] { lowerInclusive },
- new Double[] { upperValue },
- new boolean[] { upperInclusive });
- }
-
- /**
- * Create a multidimensional range query for double values indexed with {@link DoublePoint}.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
- * <p>
- * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newMultiDoubleRange(String field, Double[] lowerValue, boolean lowerInclusive[], Double[] upperValue, boolean upperInclusive[]) {
- checkArgs(field, lowerValue, upperValue);
- return new PointRangeQuery(field, DoublePoint.encode(lowerValue), lowerInclusive, DoublePoint.encode(upperValue), upperInclusive) {
- @Override
- protected String toString(byte[] value) {
- return DoublePoint.decodeDimension(value, 0).toString();
- }
- };
- }
-
- /**
- * Create a range query for matching an exact binary value.
- * <p>
- * This is for simple one-dimension points, for multidimensional points use
- * {@link #newMultiBinaryRange newMultiBinaryRange()} instead.
- *
- * @param field field name. must not be {@code null}.
- * @param value binary value
- * @throws IllegalArgumentException if {@code field} is null or {@code value} is null
- * @return a query matching documents with this exact value
- */
- public static PointRangeQuery newBinaryExact(String field, byte[] value) {
- if (value == null) {
- throw new IllegalArgumentException("value cannot be null");
- }
- return newBinaryRange(field, value, true, value, true);
- }
-
- /**
- * Create a range query for binary values indexed with {@link BinaryPoint}.
- * <p>
- * This is for simple one-dimension ranges, for multidimensional ranges use
- * {@link #newMultiBinaryRange newMultiBinaryRange()} instead.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting the {@code lowerValue} or {@code upperValue} to {@code null}.
- * <p>
- * By setting inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} means "open".
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} means "open".
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null.
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newBinaryRange(String field, byte[] lowerValue, boolean lowerInclusive, byte[] upperValue, boolean upperInclusive) {
- return newMultiBinaryRange(field, new byte[][] {lowerValue}, new boolean[] {lowerInclusive}, new byte[][] {upperValue}, new boolean[] {upperInclusive});
- }
-
- /**
- * Create a multidimensional range query for binary values indexed with {@link BinaryPoint}.
- * <p>
- * You can have half-open ranges (which are in fact </≤ or >/≥ queries)
- * by setting a {@code lowerValue} element or {@code upperValue} element to {@code null}.
- * <p>
- * By setting a dimension's inclusive ({@code lowerInclusive} or {@code upperInclusive}) to false, it will
- * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
- *
- * @param field field name. must not be {@code null}.
- * @param lowerValue lower portion of the range. {@code null} values mean "open" for that dimension.
- * @param lowerInclusive {@code true} if the lower portion of the range is inclusive, {@code false} if it should be excluded.
- * @param upperValue upper portion of the range. {@code null} values mean "open" for that dimension.
- * @param upperInclusive {@code true} if the upper portion of the range is inclusive, {@code false} if it should be excluded.
- * @throws IllegalArgumentException if {@code field} is null, or if {@code lowerValue.length != upperValue.length}
- * @return a query matching documents within this range.
- */
- public static PointRangeQuery newMultiBinaryRange(String field, byte[][] lowerValue, boolean[] lowerInclusive, byte[][] upperValue, boolean[] upperInclusive) {
- checkArgs(field, lowerValue, upperValue);
- return new PointRangeQuery(field, lowerValue, lowerInclusive, upperValue, upperInclusive);
- }
-
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
@@ -695,22 +353,8 @@ public class PointRangeQuery extends Query {
* Returns a string of a single value in a human-readable format for debugging.
* This is used by {@link #toString()}.
*
- * The default implementation encodes the individual byte values.
- *
* @param value single value, never null
* @return human readable value for debugging
*/
- protected String toString(byte[] value) {
- assert value != null;
- StringBuilder sb = new StringBuilder();
- sb.append("binary(");
- for (int i = 0; i < value.length; i++) {
- if (i > 0) {
- sb.append(' ');
- }
- sb.append(Integer.toHexString(value[i] & 0xFF));
- }
- sb.append(')');
- return sb.toString();
- }
+ protected abstract String toString(byte[] value);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
index 9a74231..0f26551 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
@@ -36,7 +36,6 @@ import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.ScoreDoc;
@@ -1352,7 +1351,7 @@ public class TestDemoParallelLeafReader extends LuceneTestCase {
max = x;
}
- TopDocs hits = s.search(PointRangeQuery.newLongRange("number", min, true, max, true), 100);
+ TopDocs hits = s.search(LongPoint.newRangeQuery("number", min, true, max, true), 100);
for(ScoreDoc scoreDoc : hits.scoreDocs) {
long value = Long.parseLong(s.doc(scoreDoc.doc).get("text").split(" ")[1]);
assertTrue(value >= min);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
index cfab5fb..bb93f2f 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
@@ -304,7 +304,7 @@ public class TestPointQueries extends LuceneTestCase {
}
if (random().nextBoolean()) {
- query = PointRangeQuery.newLongRange("sn_value", lower, includeLower, upper, includeUpper);
+ query = LongPoint.newRangeQuery("sn_value", lower, includeLower, upper, includeUpper);
} else {
byte[] lowerBytes;
if (lower == null) {
@@ -320,7 +320,7 @@ public class TestPointQueries extends LuceneTestCase {
upperBytes = new byte[8];
NumericUtils.longToBytes(upper, upperBytes, 0);
}
- query = PointRangeQuery.newBinaryRange("ss_value", lowerBytes, includeLower, upperBytes, includeUpper);
+ query = BinaryPoint.newRangeQuery("ss_value", lowerBytes, includeLower, upperBytes, includeUpper);
}
if (VERBOSE) {
@@ -586,7 +586,7 @@ public class TestPointQueries extends LuceneTestCase {
}
}
- Query query = new PointRangeQuery("value", lower, includeLower, upper, includeUpper);
+ Query query = BinaryPoint.newMultiRangeQuery("value", lower, includeLower, upper, includeUpper);
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": using query: " + query);
@@ -736,9 +736,9 @@ public class TestPointQueries extends LuceneTestCase {
IndexSearcher s = newSearcher(r);
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, 0L, true)));
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", 0L, true, Long.MAX_VALUE, true)));
- assertEquals(2, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, 0L, true)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", 0L, true, Long.MAX_VALUE, true)));
+ assertEquals(2, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
IOUtils.close(r, w, dir);
}
@@ -774,47 +774,47 @@ public class TestPointQueries extends LuceneTestCase {
IndexSearcher s = newSearcher(r);
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("aaa"),
true,
toUTF8("bbb"),
true)));
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("c", 3),
true,
toUTF8("e", 3),
true)));
- assertEquals(2, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(2, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("a", 3),
true,
toUTF8("z", 3),
true)));
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
null,
true,
toUTF8("abc"),
true)));
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("a", 3),
true,
toUTF8("abc"),
true)));
- assertEquals(0, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(0, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("a", 3),
true,
toUTF8("abc"),
false)));
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("def"),
true,
null,
false)));
- assertEquals(1, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(1, s.count(BinaryPoint.newRangeQuery("value",
toUTF8(("def")),
true,
toUTF8("z", 3),
true)));
- assertEquals(0, s.count(PointRangeQuery.newBinaryRange("value",
+ assertEquals(0, s.count(BinaryPoint.newRangeQuery("value",
toUTF8("def"),
false,
toUTF8("z", 3),
@@ -839,12 +839,12 @@ public class TestPointQueries extends LuceneTestCase {
IndexSearcher s = newSearcher(r);
- assertEquals(2, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
- assertEquals(0, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
+ assertEquals(2, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
+ assertEquals(0, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
- assertEquals(2, s.count(PointRangeQuery.newBinaryRange("value", (byte[]) null, true, null, true)));
+ assertEquals(2, s.count(BinaryPoint.newRangeQuery("value", (byte[]) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -866,12 +866,12 @@ public class TestPointQueries extends LuceneTestCase {
// We can't wrap with "exotic" readers because the query must see the RangeTreeDVFormat:
IndexSearcher s = newSearcher(r, false);
- assertEquals(2, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
- assertEquals(1, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
- assertEquals(0, s.count(PointRangeQuery.newLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
+ assertEquals(2, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
+ assertEquals(1, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
+ assertEquals(0, s.count(LongPoint.newRangeQuery("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
- assertEquals(2, s.count(PointRangeQuery.newLongRange("value", (Long) null, true, null, true)));
+ assertEquals(2, s.count(LongPoint.newRangeQuery("value", (Long) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -891,9 +891,9 @@ public class TestPointQueries extends LuceneTestCase {
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(0, s.count(PointRangeQuery.newBinaryRange("value", toUTF8("m"), true, toUTF8("n"), false)));
+ assertEquals(0, s.count(BinaryPoint.newRangeQuery("value", toUTF8("m"), true, toUTF8("n"), false)));
- assertEquals(2, s.count(PointRangeQuery.newBinaryRange("value", (byte[]) null, true, null, true)));
+ assertEquals(2, s.count(BinaryPoint.newRangeQuery("value", (byte[]) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -913,7 +913,7 @@ public class TestPointQueries extends LuceneTestCase {
IndexReader r = w.getReader();
IndexSearcher s = new IndexSearcher(r);
- assertEquals(0, s.count(PointRangeQuery.newLongRange("value", 17L, true, 13L, false)));
+ assertEquals(0, s.count(LongPoint.newRangeQuery("value", 17L, true, 13L, false)));
IOUtils.close(r, w, dir);
}
@@ -928,7 +928,7 @@ public class TestPointQueries extends LuceneTestCase {
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(0, s.count(PointRangeQuery.newLongRange("value", 17L, true, 13L, false)));
+ assertEquals(0, s.count(LongPoint.newRangeQuery("value", 17L, true, 13L, false)));
IOUtils.close(r, w, dir);
}
@@ -948,7 +948,7 @@ public class TestPointQueries extends LuceneTestCase {
IndexSearcher s = new IndexSearcher(r);
byte[][] point = new byte[2][];
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
- s.count(new PointRangeQuery("value", point, new boolean[] {true, true}, point, new boolean[] {true, true}));
+ s.count(BinaryPoint.newMultiRangeQuery("value", point, new boolean[] {true, true}, point, new boolean[] {true, true}));
});
assertEquals("field=\"value\" was indexed with numDims=1 but this query has numDims=2", expected.getMessage());
@@ -971,7 +971,7 @@ public class TestPointQueries extends LuceneTestCase {
byte[][] point = new byte[1][];
point[0] = new byte[10];
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
- s.count(new PointRangeQuery("value", point, new boolean[] {true}, point, new boolean[] {true}));
+ s.count(BinaryPoint.newMultiRangeQuery("value", point, new boolean[] {true}, point, new boolean[] {true}));
});
assertEquals("field=\"value\" was indexed with bytesPerDim=8 but this query has bytesPerDim=10", expected.getMessage());
@@ -1068,17 +1068,17 @@ public class TestPointQueries extends LuceneTestCase {
IndexReader r = DirectoryReader.open(w);
IndexSearcher s = newSearcher(r);
- assertEquals(1, s.count(PointRangeQuery.newIntExact("int", 42)));
- assertEquals(0, s.count(PointRangeQuery.newIntExact("int", 41)));
+ assertEquals(1, s.count(IntPoint.newExactQuery("int", 42)));
+ assertEquals(0, s.count(IntPoint.newExactQuery("int", 41)));
- assertEquals(1, s.count(PointRangeQuery.newLongExact("long", 5L)));
- assertEquals(0, s.count(PointRangeQuery.newLongExact("long", -1L)));
+ assertEquals(1, s.count(LongPoint.newExactQuery("long", 5L)));
+ assertEquals(0, s.count(LongPoint.newExactQuery("long", -1L)));
- assertEquals(1, s.count(PointRangeQuery.newFloatExact("float", 2.0f)));
- assertEquals(0, s.count(PointRangeQuery.newFloatExact("float", 1.0f)));
+ assertEquals(1, s.count(FloatPoint.newExactQuery("float", 2.0f)));
+ assertEquals(0, s.count(FloatPoint.newExactQuery("float", 1.0f)));
- assertEquals(1, s.count(PointRangeQuery.newDoubleExact("double", 1.0)));
- assertEquals(0, s.count(PointRangeQuery.newDoubleExact("double", 2.0)));
+ assertEquals(1, s.count(DoublePoint.newExactQuery("double", 1.0)));
+ assertEquals(0, s.count(DoublePoint.newExactQuery("double", 2.0)));
w.close();
r.close();
dir.close();
@@ -1087,27 +1087,27 @@ public class TestPointQueries extends LuceneTestCase {
public void testToString() throws Exception {
// ints
- assertEquals("field:[1 TO 2}", PointRangeQuery.newIntRange("field", 1, true, 2, false).toString());
- assertEquals("field:{-2 TO 1]", PointRangeQuery.newIntRange("field", -2, false, 1, true).toString());
- assertEquals("field:[* TO 2}", PointRangeQuery.newIntRange("field", null, true, 2, false).toString());
+ assertEquals("field:[1 TO 2}", IntPoint.newRangeQuery("field", 1, true, 2, false).toString());
+ assertEquals("field:{-2 TO 1]", IntPoint.newRangeQuery("field", -2, false, 1, true).toString());
+ assertEquals("field:[* TO 2}", IntPoint.newRangeQuery("field", null, true, 2, false).toString());
// longs
- assertEquals("field:[1099511627776 TO 2199023255552}", PointRangeQuery.newLongRange("field", 1L<<40, true, 1L<<41, false).toString());
- assertEquals("field:{-5 TO 6]", PointRangeQuery.newLongRange("field", -5L, false, 6L, true).toString());
- assertEquals("field:[* TO 2}", PointRangeQuery.newLongRange("field", null, true, 2L, false).toString());
+ assertEquals("field:[1099511627776 TO 2199023255552}", LongPoint.newRangeQuery("field", 1L<<40, true, 1L<<41, false).toString());
+ assertEquals("field:{-5 TO 6]", LongPoint.newRangeQuery("field", -5L, false, 6L, true).toString());
+ assertEquals("field:[* TO 2}", LongPoint.newRangeQuery("field", null, true, 2L, false).toString());
// floats
- assertEquals("field:[1.3 TO 2.5}", PointRangeQuery.newFloatRange("field", 1.3F, true, 2.5F, false).toString());
- assertEquals("field:{-2.9 TO 1.0]", PointRangeQuery.newFloatRange("field", -2.9F, false, 1.0F, true).toString());
- assertEquals("field:{-2.9 TO *]", PointRangeQuery.newFloatRange("field", -2.9F, false, null, true).toString());
+ assertEquals("field:[1.3 TO 2.5}", FloatPoint.newRangeQuery("field", 1.3F, true, 2.5F, false).toString());
+ assertEquals("field:{-2.9 TO 1.0]", FloatPoint.newRangeQuery("field", -2.9F, false, 1.0F, true).toString());
+ assertEquals("field:{-2.9 TO *]", FloatPoint.newRangeQuery("field", -2.9F, false, null, true).toString());
// doubles
- assertEquals("field:[1.3 TO 2.5}", PointRangeQuery.newDoubleRange("field", 1.3, true, 2.5, false).toString());
- assertEquals("field:{-2.9 TO 1.0]", PointRangeQuery.newDoubleRange("field", -2.9, false, 1.0, true).toString());
- assertEquals("field:{-2.9 TO *]", PointRangeQuery.newDoubleRange("field", -2.9, false, null, true).toString());
+ assertEquals("field:[1.3 TO 2.5}", DoublePoint.newRangeQuery("field", 1.3, true, 2.5, false).toString());
+ assertEquals("field:{-2.9 TO 1.0]", DoublePoint.newRangeQuery("field", -2.9, false, 1.0, true).toString());
+ assertEquals("field:{-2.9 TO *]", DoublePoint.newRangeQuery("field", -2.9, false, null, true).toString());
// n-dimensional double
- assertEquals("field:[1.3 TO 2.5},{-2.9 TO 1.0]", PointRangeQuery.newMultiDoubleRange("field",
+ assertEquals("field:[1.3 TO 2.5},{-2.9 TO 1.0]", DoublePoint.newMultiRangeQuery("field",
new Double[] { 1.3, -2.9 },
new boolean[] { true, false },
new Double[] { 2.5, 1.0 },
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java b/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
index 323351e..2edebb3 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
@@ -16,7 +16,7 @@
*/
package org.apache.lucene.search;
-
+import org.apache.lucene.document.IntPoint;
import org.apache.lucene.index.MultiReader;
import org.apache.lucene.index.SlowCompositeReaderWrapper;
import org.apache.lucene.index.Term;
@@ -26,7 +26,7 @@ public class TestUsageTrackingFilterCachingPolicy extends LuceneTestCase {
public void testCostlyFilter() {
assertTrue(UsageTrackingQueryCachingPolicy.isCostly(new PrefixQuery(new Term("field", "prefix"))));
- assertTrue(UsageTrackingQueryCachingPolicy.isCostly(PointRangeQuery.newIntRange("intField", 1, true, 1000, true)));
+ assertTrue(UsageTrackingQueryCachingPolicy.isCostly(IntPoint.newRangeQuery("intField", 1, true, 1000, true)));
assertFalse(UsageTrackingQueryCachingPolicy.isCostly(new TermQuery(new Term("field", "value"))));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
----------------------------------------------------------------------
diff --git a/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java b/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
index 083e41c..d9e9441 100644
--- a/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
+++ b/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
@@ -16,7 +16,6 @@
*/
package org.apache.lucene.demo.facet;
-
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.DoublePoint;
import org.apache.lucene.document.Document;
@@ -40,7 +39,6 @@ import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
@@ -181,7 +179,7 @@ public class DistanceFacetsExample implements Closeable {
BooleanQuery.Builder f = new BooleanQuery.Builder();
// Add latitude range filter:
- f.add(PointRangeQuery.newDoubleRange("latitude", Math.toDegrees(minLat), true, Math.toDegrees(maxLat), true),
+ f.add(DoublePoint.newRangeQuery("latitude", Math.toDegrees(minLat), true, Math.toDegrees(maxLat), true),
BooleanClause.Occur.FILTER);
// Add longitude range filter:
@@ -189,13 +187,13 @@ public class DistanceFacetsExample implements Closeable {
// The bounding box crosses the international date
// line:
BooleanQuery.Builder lonF = new BooleanQuery.Builder();
- lonF.add(PointRangeQuery.newDoubleRange("longitude", Math.toDegrees(minLng), true, null, true),
+ lonF.add(DoublePoint.newRangeQuery("longitude", Math.toDegrees(minLng), true, null, true),
BooleanClause.Occur.SHOULD);
- lonF.add(PointRangeQuery.newDoubleRange("longitude", null, true, Math.toDegrees(maxLng), true),
+ lonF.add(DoublePoint.newRangeQuery("longitude", null, true, Math.toDegrees(maxLng), true),
BooleanClause.Occur.SHOULD);
f.add(lonF.build(), BooleanClause.Occur.MUST);
} else {
- f.add(PointRangeQuery.newDoubleRange("longitude", Math.toDegrees(minLng), true, Math.toDegrees(maxLng), true),
+ f.add(DoublePoint.newRangeQuery("longitude", Math.toDegrees(minLng), true, Math.toDegrees(maxLng), true),
BooleanClause.Occur.FILTER);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
----------------------------------------------------------------------
diff --git a/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java b/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
index 1a7a984..96d7c17 100644
--- a/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
+++ b/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
@@ -16,7 +16,6 @@
*/
package org.apache.lucene.demo.facet;
-
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
@@ -32,7 +31,6 @@ import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TopDocs;
@@ -107,7 +105,7 @@ public class RangeFacetsExample implements Closeable {
// documents ("browse only"):
DrillDownQuery q = new DrillDownQuery(getConfig());
- q.add("timestamp", PointRangeQuery.newLongRange("timestamp", range.min, range.minInclusive, range.max, range.maxInclusive));
+ q.add("timestamp", LongPoint.newRangeQuery("timestamp", range.min, range.minInclusive, range.max, range.maxInclusive));
return searcher.search(q, 10);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
index 87f0579..f7a1970 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
@@ -54,7 +54,6 @@ import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
import org.apache.lucene.queries.function.valuesource.DoubleFieldSource;
import org.apache.lucene.queries.function.valuesource.FloatFieldSource;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
-import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
@@ -281,7 +280,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
// Third search, drill down on "less than or equal to 10":
ddq = new DrillDownQuery(config);
- ddq.add("field", PointRangeQuery.newLongRange("field", 0L, true, 10L, true));
+ ddq.add("field", LongPoint.newRangeQuery("field", 0L, true, 10L, true));
dsr = ds.search(null, ddq, 10);
assertEquals(11, dsr.hits.totalHits);
@@ -461,9 +460,9 @@ public class TestRangeFacetCounts extends FacetTestCase {
Query fastMatchQuery;
if (random().nextBoolean()) {
if (random().nextBoolean()) {
- fastMatchQuery = PointRangeQuery.newLongRange("field", minValue, true, maxValue, true);
+ fastMatchQuery = LongPoint.newRangeQuery("field", minValue, true, maxValue, true);
} else {
- fastMatchQuery = PointRangeQuery.newLongRange("field", minAcceptedValue, true, maxAcceptedValue, true);
+ fastMatchQuery = LongPoint.newRangeQuery("field", minAcceptedValue, true, maxAcceptedValue, true);
}
} else {
fastMatchQuery = null;
@@ -485,7 +484,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
// Test drill-down:
DrillDownQuery ddq = new DrillDownQuery(config);
if (random().nextBoolean()) {
- ddq.add("field", PointRangeQuery.newLongRange("field", range.min, range.minInclusive, range.max, range.maxInclusive));
+ ddq.add("field", LongPoint.newRangeQuery("field", range.min, range.minInclusive, range.max, range.maxInclusive));
} else {
ddq.add("field", range.getQuery(fastMatchQuery, vs));
}
@@ -616,9 +615,9 @@ public class TestRangeFacetCounts extends FacetTestCase {
Query fastMatchQuery;
if (random().nextBoolean()) {
if (random().nextBoolean()) {
- fastMatchQuery = PointRangeQuery.newFloatRange("field", minValue, true, maxValue, true);
+ fastMatchQuery = FloatPoint.newRangeQuery("field", minValue, true, maxValue, true);
} else {
- fastMatchQuery = PointRangeQuery.newFloatRange("field", minAcceptedValue, true, maxAcceptedValue, true);
+ fastMatchQuery = FloatPoint.newRangeQuery("field", minAcceptedValue, true, maxAcceptedValue, true);
}
} else {
fastMatchQuery = null;
@@ -640,7 +639,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
// Test drill-down:
DrillDownQuery ddq = new DrillDownQuery(config);
if (random().nextBoolean()) {
- ddq.add("field", PointRangeQuery.newFloatRange("field", (float) range.min, range.minInclusive, (float) range.max, range.maxInclusive));
+ ddq.add("field", FloatPoint.newRangeQuery("field", (float) range.min, range.minInclusive, (float) range.max, range.maxInclusive));
} else {
ddq.add("field", range.getQuery(fastMatchQuery, vs));
}
@@ -755,9 +754,9 @@ public class TestRangeFacetCounts extends FacetTestCase {
Query fastMatchFilter;
if (random().nextBoolean()) {
if (random().nextBoolean()) {
- fastMatchFilter = PointRangeQuery.newDoubleRange("field", minValue, true, maxValue, true);
+ fastMatchFilter = DoublePoint.newRangeQuery("field", minValue, true, maxValue, true);
} else {
- fastMatchFilter = PointRangeQuery.newDoubleRange("field", minAcceptedValue, true, maxAcceptedValue, true);
+ fastMatchFilter = DoublePoint.newRangeQuery("field", minAcceptedValue, true, maxAcceptedValue, true);
}
} else {
fastMatchFilter = null;
@@ -779,7 +778,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
// Test drill-down:
DrillDownQuery ddq = new DrillDownQuery(config);
if (random().nextBoolean()) {
- ddq.add("field", PointRangeQuery.newDoubleRange("field", range.min, range.minInclusive, range.max, range.maxInclusive));
+ ddq.add("field", DoublePoint.newRangeQuery("field", range.min, range.minInclusive, range.max, range.maxInclusive));
} else {
ddq.add("field", range.getQuery(fastMatchFilter, vs));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/099e0311/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
----------------------------------------------------------------------
diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index 58f1eb9..edc91f6 100644
--- a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -62,7 +62,6 @@ import org.apache.lucene.queries.payloads.SpanPayloadCheckQuery;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
-import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiPhraseQuery;
@@ -584,7 +583,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void testDimensionalRangeQuery() throws Exception {
// doesn't currently highlight, but make sure it doesn't cause exception either
- query = PointRangeQuery.newIntRange(NUMERIC_FIELD_NAME, 2, true, 6, true);
+ query = IntPoint.newRangeQuery(NUMERIC_FIELD_NAME, 2, true, 6, true);
searcher = newSearcher(reader);
hits = searcher.search(query, 100);
int maxNumFragmentsRequired = 2;