Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-2935: Better docs for numeric FieldTypes

Chris M. Hostetter3fc07698f3a8
diff --git a/solr/core/src/java/org/apache/solr/schema/ByteField.java b/solr/core/src/java/org/apache/solr/schema/ByteField.java
index f584bf9528b..093c0dde9cc 100644
--- a/solr/core/src/java/org/apache/solr/schema/ByteField.java
+++ b/solr/core/src/java/org/apache/solr/schema/ByteField.java
@@ -28,7 +28,21 @@ import java.io.IOException;
import java.util.Map;
/**
+ * A numeric field that can contain 8-bit signed two's complement integer
+ * values, encoded as simple Strings.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
+ *
+ * <ul>
+ * <li>Min Value Allowed: -128</li>
+ * <li>Max Value Allowed: 127</li>
+ * </ul>
+ *
+ * @see Byte
*/
public class ByteField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/DoubleField.java b/solr/core/src/java/org/apache/solr/schema/DoubleField.java
index 22e34c96407..3131fa094b9 100644
--- a/solr/core/src/java/org/apache/solr/schema/DoubleField.java
+++ b/solr/core/src/java/org/apache/solr/schema/DoubleField.java
@@ -28,7 +28,18 @@ import java.io.IOException;
import java.util.Map;
/**
+ * A legacy numeric field type that encodes "Double" values as simple Strings.
+ * This class should not be used except by people with existing indexes that
+ * contain numeric values indexed as Strings.
+ * New schemas should use {@link TrieDoubleField}.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
+ *
+ * @see TrieDoubleField
*/
public class DoubleField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/FloatField.java b/solr/core/src/java/org/apache/solr/schema/FloatField.java
index e784d70d756..4229638dc96 100644
--- a/solr/core/src/java/org/apache/solr/schema/FloatField.java
+++ b/solr/core/src/java/org/apache/solr/schema/FloatField.java
@@ -27,7 +27,18 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
/**
+ * A legacy numeric field type that encodes "Float" values as simple Strings.
+ * This class should not be used except by people with existing indexes that
+ * contain numeric values indexed as Strings.
+ * New schemas should use {@link TrieFloatField}.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
+ *
+ * @see TrieFloatField
*/
public class FloatField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/IntField.java b/solr/core/src/java/org/apache/solr/schema/IntField.java
index 3c1b1944cd8..c074d5338cd 100644
--- a/solr/core/src/java/org/apache/solr/schema/IntField.java
+++ b/solr/core/src/java/org/apache/solr/schema/IntField.java
@@ -27,7 +27,18 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
/**
+ * A legacy numeric field type that encodes "Integer" values as simple Strings.
+ * This class should not be used except by people with existing indexes that
+ * contain numeric values indexed as Strings.
+ * New schemas should use {@link TrieIntField}.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
+ *
+ * @see TrieIntField
*/
public class IntField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/LongField.java b/solr/core/src/java/org/apache/solr/schema/LongField.java
index 7c8e066ac45..a8fe83b715e 100644
--- a/solr/core/src/java/org/apache/solr/schema/LongField.java
+++ b/solr/core/src/java/org/apache/solr/schema/LongField.java
@@ -27,7 +27,18 @@ import org.apache.solr.search.QParser;
import java.io.IOException;
import java.util.Map;
/**
+ * A legacy numeric field type that encodes "Long" values as simple Strings.
+ * This class should not be used except by people with existing indexes that
+ * contain numeric values indexed as Strings.
+ * New schemas should use {@link TrieLongField}.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
+ *
+ * @see TrieLongField
*/
public class LongField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/ShortField.java b/solr/core/src/java/org/apache/solr/schema/ShortField.java
index 7520d58d21c..59cab5a3f05 100644
--- a/solr/core/src/java/org/apache/solr/schema/ShortField.java
+++ b/solr/core/src/java/org/apache/solr/schema/ShortField.java
@@ -29,8 +29,21 @@ import java.util.Map;
/**
+ * A numeric field that can contain 16-bit signed two's complement integer
+ * values, encoded as simple Strings.
*
+ * <p>
+ * Field values will sort numerically, but Range Queries (and other features
+ * that rely on numeric ranges) will not work as expected: values will be
+ * evaluated in unicode String order, not numeric order.
+ * </p>
*
+ * <ul>
+ * <li>Min Value Allowed: -32768</li>
+ * <li>Max Value Allowed: 32767</li>
+ * </ul>
+ *
+ * @see Short
**/
public class ShortField extends FieldType {
@Override
diff --git a/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java b/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java
index 9bd93499b69..a9facc51365 100644
--- a/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java
+++ b/solr/core/src/java/org/apache/solr/schema/SortableDoubleField.java
@@ -36,8 +36,19 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
/**
+ * A legacy numeric field type that encodes "Double" values as Strings such
+ * that Term enumeration order matches the natural numeric order. This class
+ * should not be used except by people with existing indexes that already
+ * contain fields of this type. New schemas should use {@link TrieDoubleField}.
*
+ * <p>
+ * The naming convention "Sortable" comes from the fact that both the numeric
+ * values and encoded String representations Sort identically (as opposed to
+ * a direct String representation where values such as "11" sort before values
+ * such as "2").
+ * </p>
*
+ * @see TrieDoubleField
* @deprecated use {@link DoubleField} or {@link TrieDoubleField} - will be removed in 5.x
*/
@Deprecated
diff --git a/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java b/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java
index 1ed0edf5074..11aeb4bbbfe 100644
--- a/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java
+++ b/solr/core/src/java/org/apache/solr/schema/SortableFloatField.java
@@ -35,9 +35,21 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
+
/**
+ * A legacy numeric field type that encodes "Float" values as Strings such
+ * that Term enumeration order matches the natural numeric order. This class
+ * should not be used except by people with existing indexes that already
+ * contain fields of this type. New schemas should use {@link TrieFloatField}.
+ *
+ * <p>
+ * The naming convention "Sortable" comes from the fact that both the numeric
+ * values and encoded String representations Sort identically (as opposed to
+ * a direct String representation where values such as "11" sort before values
+ * such as "2").
+ * </p>
*
- *
+ * @see TrieFloatField
* @deprecated use {@link FloatField} or {@link TrieFloatField} - will be removed in 5.x
*/
@Deprecated
diff --git a/solr/core/src/java/org/apache/solr/schema/SortableIntField.java b/solr/core/src/java/org/apache/solr/schema/SortableIntField.java
index 834bd645f47..810e1390168 100644
--- a/solr/core/src/java/org/apache/solr/schema/SortableIntField.java
+++ b/solr/core/src/java/org/apache/solr/schema/SortableIntField.java
@@ -35,9 +35,21 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
+
/**
+ * A legacy numeric field type that encodes "Integer" values as Strings such
+ * that Term enumeration order matches the natural numeric order. This class
+ * should not be used except by people with existing indexes that already
+ * contain fields of this type. New schemas should use {@link TrieIntField}.
*
+ * <p>
+ * The naming convention "Sortable" comes from the fact that both the numeric
+ * values and encoded String representations Sort identically (as opposed to
+ * a direct String representation where values such as "11" sort before values
+ * such as "2").
+ * </p>
*
+ * @see TrieIntField
* @deprecated use {@link IntField} or {@link TrieIntField} - will be removed in 5.x
*/
@Deprecated
diff --git a/solr/core/src/java/org/apache/solr/schema/SortableLongField.java b/solr/core/src/java/org/apache/solr/schema/SortableLongField.java
index 0e0b3a52906..ce5b2cc2475 100644
--- a/solr/core/src/java/org/apache/solr/schema/SortableLongField.java
+++ b/solr/core/src/java/org/apache/solr/schema/SortableLongField.java
@@ -36,8 +36,19 @@ import org.apache.solr.response.TextResponseWriter;
import java.util.Map;
import java.io.IOException;
/**
+ * A legacy numeric field type that encodes "Long" values as Strings such
+ * that Term enumeration order matches the natural numeric order. This class
+ * should not be used except by people with existing indexes that already
+ * contain fields of this type. New schemas should use {@link TrieLongField}.
*
+ * <p>
+ * The naming convention "Sortable" comes from the fact that both the numeric
+ * values and encoded String representations Sort identically (as opposed to
+ * a direct String representation where values such as "11" sort before values
+ * such as "2").
+ * </p>
*
+ * @see TrieLongField
* @deprecated use {@link LongField} or {@link TrieLongField} - will be removed in 5.x
*/
@Deprecated
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java b/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
index 3ca211b2168..d5dba1aef14 100755
--- a/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieDoubleField.java
@@ -17,6 +17,22 @@
package org.apache.solr.schema;
+/**
+ * A numeric field that can contain double-precision 64-bit IEEE 754 floating
+ * point values.
+ *
+ * <ul>
+ * <li>Min Value Allowed: 4.9E-324</li>
+ * <li>Max Value Allowed: 1.7976931348623157E308</li>
+ * </ul>
+ *
+ * <b>NOTE:</b> The behavior of this class when given values of
+ * {@link Double#NaN}, {@link Double#NEGATIVE_INFINITY}, or
+ * {@link Double#POSITIVE_INFINITY} is undefined.
+ *
+ * @see Double
+ * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3">Java Language Specification, s4.2.3</a>
+ */
public class TrieDoubleField extends TrieField {
{
type=TrieTypes.DOUBLE;
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java b/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
index 91226f31348..3c8326974a2 100755
--- a/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieFloatField.java
@@ -17,6 +17,22 @@
package org.apache.solr.schema;
+/**
+ * A numeric field that can contain single-precision 32-bit IEEE 754
+ * floating point values.
+ *
+ * <ul>
+ * <li>Min Value Allowed: 1.401298464324817E-45</li>
+ * <li>Max Value Allowed: 3.4028234663852886E38</li>
+ * </ul>
+ *
+ * <b>NOTE:</b> The behavior of this class when given values of
+ * {@link Float#NaN}, {@link Float#NEGATIVE_INFINITY}, or
+ * {@link Float#POSITIVE_INFINITY} is undefined.
+ *
+ * @see Float
+ * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3">Java Language Specification, s4.2.3</a>
+ */
public class TrieFloatField extends TrieField {
{
type=TrieTypes.FLOAT;
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieIntField.java b/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
index 999193fe917..12a26da9683 100755
--- a/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieIntField.java
@@ -17,6 +17,16 @@
package org.apache.solr.schema;
+/**
+ * A numeric field that can contain 32-bit signed two's complement integer values.
+ *
+ * <ul>
+ * <li>Min Value Allowed: -2147483648</li>
+ * <li>Max Value Allowed: 2147483647</li>
+ * </ul>
+ *
+ * @see Integer
+ */
public class TrieIntField extends TrieField {
{
type=TrieTypes.INTEGER;
diff --git a/solr/core/src/java/org/apache/solr/schema/TrieLongField.java b/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
index 6e2272b26d0..e0c0f2c0d39 100755
--- a/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
+++ b/solr/core/src/java/org/apache/solr/schema/TrieLongField.java
@@ -17,6 +17,16 @@
package org.apache.solr.schema;
+/**
+ * A numeric field that can contain 64-bit signed two's complement integer values.
+ *
+ * <ul>
+ * <li>Min Value Allowed: -9223372036854775808</li>
+ * <li>Max Value Allowed: 9223372036854775807</li>
+ * </ul>
+ *
+ * @see Long
+ */
public class TrieLongField extends TrieField {
{
type=TrieTypes.LONG;