Index: src/java/org/apache/lucene/analysis/NumericTokenStream.java =================================================================== --- src/java/org/apache/lucene/analysis/NumericTokenStream.java (revision 809202) +++ src/java/org/apache/lucene/analysis/NumericTokenStream.java (working copy) @@ -42,38 +42,39 @@ *

See {@link NumericField} for capabilities of fields * indexed numerically.

* - *

Here's an example usage, for an int field: + *

Here's an example usage, for an int field: * *

- *   Field field = new Field(name, new NumericTokenStream(precisionStep).setIntValue(value));
- *   field.setOmitNorms(true);
- *   field.setOmitTermFreqAndPositions(true);
- *   document.add(field);
+ *  Field field = new Field(name, new NumericTokenStream(precisionStep).setIntValue(value));
+ *  field.setOmitNorms(true);
+ *  field.setOmitTermFreqAndPositions(true);
+ *  document.add(field);
  * 
* *

For optimal performance, re-use the TokenStream and Field instance * for more than one document: * *

- *   NumericTokenStream stream = new NumericTokenStream(precisionStep);
- *   Field field = new Field(name, stream);
- *   field.setOmitNorms(true);
- *   field.setOmitTermFreqAndPositions(true);
- *   Document document = new Document();
- *   document.add(field);
- *   for(all documents) {
- *     stream.setIntValue(value)
- *     writer.addDocument(document);
- *   }
+ *  NumericTokenStream stream = new NumericTokenStream(precisionStep);
+ *  Field field = new Field(name, stream);
+ *  field.setOmitNorms(true);
+ *  field.setOmitTermFreqAndPositions(true);
+ *  Document document = new Document();
+ *  document.add(field);
+ *
+ *  for(all documents) {
+ *    stream.setIntValue(value)
+ *    writer.addDocument(document);
+ *  }
  * 
* *

This stream is not intended to be used in analyzers; * it's more for iterating the different precisions during * indexing a specific numeric value.

- *

NOTE: as TokenStreams are only consumed once - * the Document is added to the index, if you index more - * than one numeric field, use a separate NumericTokenStream + *

NOTE: as token streams are only consumed once + * the document is added to the index, if you index more + * than one numeric field, use a separate NumericTokenStream * instance for each.

* *

See {@link NumericRangeQuery} for more details on the Index: src/java/org/apache/lucene/document/NumericField.java =================================================================== --- src/java/org/apache/lucene/document/NumericField.java (revision 809202) +++ src/java/org/apache/lucene/document/NumericField.java (working copy) @@ -32,15 +32,14 @@ * of numeric values for efficient range filtering and * sorting. Here's an example usage, adding an int value: *

- *   document.add(new NumericField(name).setIntValue(value));
+ *  document.add(new NumericField(name).setIntValue(value));
  * 
* * For optimal performance, re-use the - * NumericField and {@link Document} instance for more than + * NumericField and {@link Document} instance for more than * one document: * *
- *  // init
  *  NumericField field = new NumericField(name);
  *  Document document = new Document();
  *  document.add(field);
@@ -53,46 +52,50 @@
  *  }
  * 
* - *

The java native types int, long, float and double are + *

The java native types int, long, + * float and double are * directly supported. However, any value that can be * converted into these native types can also be indexed. * For example, date/time values represented by a - * java.util.Date can be translated into a long - * value using the getTime method. If you + * {@link java.util.Date} can be translated into a long + * value using the {@link java.util.Date#getTime} method. If you * don't need millisecond precision, you can quantize the * value, either by dividing the result of - * getTime or using the separate getters (for - * year, month, etc.) to construct an int or long value.

+ * {@link java.util.Date#getTime} or using the separate getters + * (for year, month, etc.) to construct an int or + * long value.

* *

To perform range querying or filtering against a - * NumericField, use {@link NumericRangeQuery} or {@link + * NumericField, use {@link NumericRangeQuery} or {@link * NumericRangeFilter}. To sort according to a - * NumericField, use the normal numeric sort types, eg + * NumericField, use the normal numeric sort types, eg * {@link SortField#INT} (note that {@link SortField#AUTO} - * will not work with these fields). NumericField values + * will not work with these fields). NumericField values * can also be loaded directly from {@link FieldCache}.

* - *

By default, a NumericField's value is not stored but + *

By default, a NumericField's value is not stored but * is indexed for range filtering and sorting. You can use * the {@link #NumericField(String,Field.Store,boolean)} * constructor if you need to change these defaults.

* - *

You may add the same field name as a NumericField to + *

You may add the same field name as a NumericField to * the same document more than once. Range querying and - * filtering will be the logical OR of all values, however - * sort behavior is not defined. If you need to sort, you - * should separately index a single-valued NumericField.

+ * filtering will be the logical OR of all values; so a range query + * will hit all documents that have at least one value in + * the range. However sort behavior is not defined. If you need to sort, + * you should separately index a single-valued NumericField.

* - *

A NumericField will consume somewhat more disk space + *

A NumericField will consume somewhat more disk space * in the index than an ordindary single-valued field. * However, for a typical index that includes substantial * textual content per document, this increase will likely * be in the noise.

* - *

Within lucene, each numeric value is indexed as a + *

Within Lucene, each numeric value is indexed as a * trie structure, where each term is logically - * assigned to larger and larger pre-defined brackets. The - * step size between each successive bracket is called the + * assigned to larger and larger pre-defined brackets (which + * are simply lower-precision representations of the value). + * The step size between each successive bracket is called the * precisionStep, measured in bits. Smaller * precisionStep values result in larger number * of brackets, which consumes more disk space in the index @@ -105,6 +108,12 @@ * specify a congruent value when creating {@link * NumericRangeQuery} or {@link NumericRangeFilter}. * + *

For more information on the internals of numeric trie + * indexing, including the precisionStep + * configuration, see {@link NumericRangeQuery}. The format of + * indexed values is described in {@link NumericUtils}. + * *

If you only need to sort by numeric value, and never * run range querying/filtering, you can index using a * precisionStep of {@link Integer#MAX_VALUE}. @@ -115,11 +124,6 @@ * class is a wrapper around this token stream type for * easier, more intuitive usage.

* - *

For more information on the internals of numeric trie - * indexing, including the precisionStep - * configuration, see {@link NumericRangeQuery}. - * *

NOTE: This class is only used during * indexing. When retrieving the stored field value from a * {@link Document} instance after search, you will get a Index: src/java/org/apache/lucene/search/NumericRangeFilter.java =================================================================== --- src/java/org/apache/lucene/search/NumericRangeFilter.java (revision 809202) +++ src/java/org/apache/lucene/search/NumericRangeFilter.java (working copy) @@ -38,14 +38,13 @@ * * accepts all documents whose float valued "weight" field * ranges from 0.3 to 0.10, inclusive. + * See {@link NumericRangeQuery} for details on how Lucene + * indexes and searches numeric valued fields. * *

NOTE: This API is experimental and * might change in incompatible ways in the next * release. * - * See {@link NumericRangeQuery} for details on how Lucene - * indexes and searches numeric valued fields. - * * @since 2.9 **/ public final class NumericRangeFilter extends MultiTermQueryWrapperFilter { Index: src/java/org/apache/lucene/search/NumericRangeQuery.java =================================================================== --- src/java/org/apache/lucene/search/NumericRangeQuery.java (revision 809202) +++ src/java/org/apache/lucene/search/NumericRangeQuery.java (working copy) @@ -79,9 +79,8 @@ *

NOTE: This API is experimental and * might change in incompatible ways in the next release. * + *

How it works

* - *

How it works

- * *

See the publication about panFMP, * where this algorithm was described (referred to as TrieRangeQuery): *