To use this, you must first index the numeric values using {@link NumericField} (expert: {@link NumericTokenStream}). If your terms are instead textual, you should use {@link NodeTermRangeQuery}.
You create a new {@link NodeNumericRangeQuery} with the staticfactory methods, eg:
Query q = NodeNumericRangeQuery.newFloatRange("weight", 0.03f, 0.10f, true, true);matches all documents whose float valued "weight" field ranges from 0.03 to 0.10, inclusive.
The performance of {@link NodeNumericRangeQuery} is much betterthan the corresponding {@link NodeTermRangeQuery} because thenumber of terms that must be searched is usually far fewer, thanks to trie indexing, described below.
You can optionally specify a precisionStep
when creating this query. This is necessary if you've changed this configuration from its default (4) during indexing. Lower values consume more disk space but speed up searching. Suitable values are between 1 and 8. A good starting point to test is 4, which is the default value for all Numeric*
classes. See below for details.
This query defaults to {@linkplain MultiNodeTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT} and never relies onuses {@linkplain MultiNodeTermQuery#CONSTANT_SCORE_FILTER_REWRITE}. Good performance is expected for 32 bit (int/float) ranges with precisionStep ≤8 and 64 bit (long/double) ranges with precisionStep ≤6. In the other cases, bad performance has to be expected as the number of terms is likely to be high.
See {@link NumericRangeQuery} for more information on how it works.
Code taken from {@link NumericRangeQuery} and adapted for SIREn.
|
|