Skip to content

Apache Lucene open-source search software

LUCENE-3582: Add javadocs

Uwe Schindler4dc8f2c8b1ca
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<T extends Number> extends MultiTermQueryWr
* Factory that creates a <code>NumericRangeFilter</code>, that filters a <code>double</code>
* range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><code>precisionStep</code></a>.
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Double> newDoubleRange(final String field, final int precisionStep,
@@ -126,7 +128,9 @@ public final class NumericRangeFilter<T extends Number> extends MultiTermQueryWr
* Factory that creates a <code>NumericRangeFilter</code>, that queries a <code>double</code>
* range using the default <code>precisionStep</code> {@link NumericUtils#PRECISION_STEP_DEFAULT} (4).
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Double> newDoubleRange(final String field,
@@ -141,7 +145,9 @@ public final class NumericRangeFilter<T extends Number> extends MultiTermQueryWr
* Factory that creates a <code>NumericRangeFilter</code>, that filters a <code>float</code>
* range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><code>precisionStep</code></a>.
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Float> newFloatRange(final String field, final int precisionStep,
@@ -156,7 +162,9 @@ public final class NumericRangeFilter<T extends Number> extends MultiTermQueryWr
* Factory that creates a <code>NumericRangeFilter</code>, that queries a <code>float</code>
* range using the default <code>precisionStep</code> {@link NumericUtils#PRECISION_STEP_DEFAULT} (4).
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Float> 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<T extends Number> extends MultiTermQuery {
* Factory that creates a <code>NumericRangeQuery</code>, that queries a <code>double</code>
* range using the given <a href="#precisionStepDesc"><code>precisionStep</code></a>.
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Double> newDoubleRange(final String field, final int precisionStep,
@@ -267,7 +269,9 @@ public final class NumericRangeQuery<T extends Number> extends MultiTermQuery {
* Factory that creates a <code>NumericRangeQuery</code>, that queries a <code>double</code>
* range using the default <code>precisionStep</code> {@link NumericUtils#PRECISION_STEP_DEFAULT} (4).
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Double> newDoubleRange(final String field,
@@ -280,7 +284,9 @@ public final class NumericRangeQuery<T extends Number> extends MultiTermQuery {
* Factory that creates a <code>NumericRangeQuery</code>, that queries a <code>float</code>
* range using the given <a href="#precisionStepDesc"><code>precisionStep</code></a>.
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Float> newFloatRange(final String field, final int precisionStep,
@@ -293,7 +299,9 @@ public final class NumericRangeQuery<T extends Number> extends MultiTermQuery {
* Factory that creates a <code>NumericRangeQuery</code>, that queries a <code>float</code>
* range using the default <code>precisionStep</code> {@link NumericUtils#PRECISION_STEP_DEFAULT} (4).
* You can have half-open ranges (which are in fact &lt;/&le; or &gt;/&ge; queries)
- * by setting the min or max value to <code>null</code>. By setting inclusive to false, it will
+ * by setting the min or max value to <code>null</code>.
+ * {@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<Float> 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 &quot;double format&quot;
* 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 &quot;float format&quot;
* 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) {