java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.sandbox.search.MultiRangeQuery
- All Implemented Interfaces:
Cloneable
Abstract class for range queries involving multiple ranges against physical points such as
IntPoints
All ranges are logically ORed together-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A builder for multirange queries.private static interface
A range represents anything with a min/max value that can compute its relation with another range and can compute if a point is inside itstatic final class
Representation of a single clause in a MultiRangeQueryprivate static class
An interval tree of Ranges for speeding up computationsprivate static interface
Represents a range that can compute its relation with another range and can compute if a point is inside it -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int
(package private) final String
(package private) final int
(package private) List<MultiRangeQuery.RangeClause>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
MultiRangeQuery
(String field, int numDims, int bytesPerDim, List<MultiRangeQuery.RangeClause> rangeClauses) Expert: create a multidimensional range query with multiple connected ranges -
Method Summary
Modifier and TypeMethodDescription(package private) static MultiRangeQuery.RangeTree
createTree
(List<MultiRangeQuery.RangeClause> clauses, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Creates a tree from provided clausesprivate static MultiRangeQuery.RangeTree
createTree
(MultiRangeQuery.Range[] components, int low, int high, int split, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Creates tree from sorted ranges (with range low and high inclusive)final Weight
createWeight
(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.final boolean
Override and implement query instance equivalence properly in a subclass.private boolean
equalsTo
(MultiRangeQuery other) int
getField()
int
private static MultiRangeQuery.Range
getRange
(MultiRangeQuery.RangeClause clause, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Builds a Range object from a range clausefinal int
hashCode()
Override and implement query hash code properly in a subclass.(package private) static List<MultiRangeQuery.RangeClause>
mergeOverlappingRanges
(List<MultiRangeQuery.RangeClause> rangeClauses, int bytesPerDim) Merges overlapping ranges and returns unconnected rangesrewrite
(IndexReader reader) Merges the overlapping ranges and returns unconnected ranges by callingmergeOverlappingRanges(java.util.List<org.apache.lucene.sandbox.search.MultiRangeQuery.RangeClause>, int)
protected abstract String
toString
(int dimension, byte[] value) Returns a string of a single value in a human-readable format for debugging.final String
Prints a query to a string, withfield
assumed to be the default field and omitted.void
visit
(QueryVisitor visitor) Recurse through the query tree, visiting any child queriesMethods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toString
-
Field Details
-
field
-
numDims
final int numDims -
bytesPerDim
final int bytesPerDim -
rangeClauses
List<MultiRangeQuery.RangeClause> rangeClauses
-
-
Constructor Details
-
MultiRangeQuery
protected MultiRangeQuery(String field, int numDims, int bytesPerDim, List<MultiRangeQuery.RangeClause> rangeClauses) Expert: create a multidimensional range query with multiple connected ranges- Parameters:
field
- field name. must not benull
.rangeClauses
- Range Clauses for this querynumDims
- number of dimensions.
-
-
Method Details
-
visit
Description copied from class:Query
Recurse through the query tree, visiting any child queries -
rewrite
Merges the overlapping ranges and returns unconnected ranges by callingmergeOverlappingRanges(java.util.List<org.apache.lucene.sandbox.search.MultiRangeQuery.RangeClause>, int)
- Overrides:
rewrite
in classQuery
- Throws:
IOException
- See Also:
-
mergeOverlappingRanges
static List<MultiRangeQuery.RangeClause> mergeOverlappingRanges(List<MultiRangeQuery.RangeClause> rangeClauses, int bytesPerDim) Merges overlapping ranges and returns unconnected ranges- Parameters:
rangeClauses
- some overlapping rangesbytesPerDim
- bytes per Dimension of the point value- Returns:
- unconnected ranges
-
createWeight
public final Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException Description copied from class:Query
Expert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeight
in classQuery
scoreMode
- How the produced scorers will be consumed.boost
- The boost that is propagated by the parent queries.- Throws:
IOException
-
getField
-
getNumDims
public int getNumDims() -
getBytesPerDim
public int getBytesPerDim() -
hashCode
public final int hashCode()Description copied from class:Query
Override and implement query hash code properly in a subclass. This is required so thatQueryCache
works properly. -
equals
Description copied from class:Query
Override and implement query instance equivalence properly in a subclass. This is required so thatQueryCache
works properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical that other instance. Utility methods are provided for certain repetitive code.
-
equalsTo
-
toString
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted. -
toString
Returns a string of a single value in a human-readable format for debugging. This is used byQuery.toString()
.- Parameters:
dimension
- dimension of the particular valuevalue
- single value, never null- Returns:
- human readable value for debugging
-
createTree
static MultiRangeQuery.RangeTree createTree(List<MultiRangeQuery.RangeClause> clauses, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Creates a tree from provided clauses -
createTree
private static MultiRangeQuery.RangeTree createTree(MultiRangeQuery.Range[] components, int low, int high, int split, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Creates tree from sorted ranges (with range low and high inclusive) -
getRange
private static MultiRangeQuery.Range getRange(MultiRangeQuery.RangeClause clause, int numIndexDim, int bytesPerDim, ArrayUtil.ByteArrayComparator comparator) Builds a Range object from a range clause
-