diff --git a/lucene/src/java/org/apache/lucene/search/NumericRangeFilter.java b/lucene/src/java/org/apache/lucene/search/NumericRangeFilter.java index 116972a0fbe..a2977e71651 100644 --- a/lucene/src/java/org/apache/lucene/search/NumericRangeFilter.java +++ b/lucene/src/java/org/apache/lucene/search/NumericRangeFilter.java @@ -111,7 +111,9 @@ public final class NumericRangeFilter extends MultiTermQueryWr * Factory that creates a NumericRangeFilter, that filters a double * range using the given precisionStep. * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Double#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Double.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeFilter newDoubleRange(final String field, final int precisionStep, @@ -126,7 +128,9 @@ public final class NumericRangeFilter extends MultiTermQueryWr * Factory that creates a NumericRangeFilter, that queries a double * range using the default precisionStep {@link NumericUtils#PRECISION_STEP_DEFAULT} (4). * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Double#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Double.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeFilter newDoubleRange(final String field, @@ -141,7 +145,9 @@ public final class NumericRangeFilter extends MultiTermQueryWr * Factory that creates a NumericRangeFilter, that filters a float * range using the given precisionStep. * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Float#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Float.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeFilter newFloatRange(final String field, final int precisionStep, @@ -156,7 +162,9 @@ public final class NumericRangeFilter extends MultiTermQueryWr * Factory that creates a NumericRangeFilter, that queries a float * range using the default precisionStep {@link NumericUtils#PRECISION_STEP_DEFAULT} (4). * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Float#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Float.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeFilter newFloatRange(final String field, diff --git a/lucene/src/java/org/apache/lucene/search/NumericRangeQuery.java b/lucene/src/java/org/apache/lucene/search/NumericRangeQuery.java index feb95a3e740..c446ceffd60 100644 --- a/lucene/src/java/org/apache/lucene/search/NumericRangeQuery.java +++ b/lucene/src/java/org/apache/lucene/search/NumericRangeQuery.java @@ -254,7 +254,9 @@ public final class NumericRangeQuery extends MultiTermQuery { * Factory that creates a NumericRangeQuery, that queries a double * range using the given precisionStep. * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Double#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Double.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeQuery newDoubleRange(final String field, final int precisionStep, @@ -267,7 +269,9 @@ public final class NumericRangeQuery extends MultiTermQuery { * Factory that creates a NumericRangeQuery, that queries a double * range using the default precisionStep {@link NumericUtils#PRECISION_STEP_DEFAULT} (4). * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Double#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Double.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeQuery newDoubleRange(final String field, @@ -280,7 +284,9 @@ public final class NumericRangeQuery extends MultiTermQuery { * Factory that creates a NumericRangeQuery, that queries a float * range using the given precisionStep. * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Float#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Float.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeQuery newFloatRange(final String field, final int precisionStep, @@ -293,7 +299,9 @@ public final class NumericRangeQuery extends MultiTermQuery { * Factory that creates a NumericRangeQuery, that queries a float * range using the default precisionStep {@link NumericUtils#PRECISION_STEP_DEFAULT} (4). * You can have half-open ranges (which are in fact </≤ or >/≥ queries) - * by setting the min or max value to null. By setting inclusive to false, it will + * by setting the min or max value to null. + * {@link Float#NaN} will never match a half-open range, to hit {@code NaN} use a query + * with {@code min == max == Float.NaN}. By setting inclusive to false, it will * match all documents excluding the bounds, with inclusive on, the boundaries are hits, too. */ public static NumericRangeQuery newFloatRange(final String field, diff --git a/lucene/src/java/org/apache/lucene/util/NumericUtils.java b/lucene/src/java/org/apache/lucene/util/NumericUtils.java index 527fbbf7ec5..f6e60f7f748 100644 --- a/lucene/src/java/org/apache/lucene/util/NumericUtils.java +++ b/lucene/src/java/org/apache/lucene/util/NumericUtils.java @@ -239,6 +239,8 @@ public final class NumericUtils { * The value is converted by getting their IEEE 754 floating-point "double format" * bit layout and then some bits are swapped, to be able to compare the result as long. * By this the precision is not reduced, but the value can easily used as a long. + * The sort order (including {@link Double#NaN}) is defined by + * {@link Double#compareTo}; {@code NaN} is greater than positive infinity. * @see #sortableLongToDouble */ public static long doubleToSortableLong(double val) { @@ -261,6 +263,8 @@ public final class NumericUtils { * The value is converted by getting their IEEE 754 floating-point "float format" * bit layout and then some bits are swapped, to be able to compare the result as int. * By this the precision is not reduced, but the value can easily used as an int. + * The sort order (including {@link Float#NaN}) is defined by + * {@link Float#compareTo}; {@code NaN} is greater than positive infinity. * @see #sortableIntToFloat */ public static int floatToSortableInt(float val) {