org.apache.lucene.search
Class RangeQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.RangeQuery
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class RangeQuery extends Query
A Query that matches documents within an exclusive range. A RangeQuery is built by QueryParser for input like[010 TO 120]but only if the QueryParser has the useOldRangeQuery property set to true. The QueryParser default behaviour is to use the newer ConstantScoreRangeQuery class. This is generally preferable because:- It is faster than RangeQuery
- Unlike RangeQuery, it does not cause a BooleanQuery.TooManyClauses exception if the range of values is large
- Unlike RangeQuery it does not influence scoring based on the scarcity of individual terms that may match
- See Also:
ConstantScoreRangeQuery, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive)Constructs a query selecting all terms greater thanlowerTermbut less thanupperTerm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanequals(java.lang.Object o)Returns true iffois equal to this.java.lang.StringgetField()Returns the field name for this queryTermgetLowerTerm()Returns the lower term of this range queryTermgetUpperTerm()Returns the upper term of this range queryinthashCode()Returns a hash code value for this object.booleanisInclusive()Returnstrueif the range query is inclusiveQueryrewrite(IndexReader reader)Expert: called to re-write queries into primitive queries.java.lang.StringtoString(java.lang.String field)Prints a user-readable version of this query.-
Methods inherited from class org.apache.lucene.search.Query
clone, combine, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
-
-
-
-
Constructor Detail
-
RangeQuery
public RangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive)
Constructs a query selecting all terms greater thanlowerTermbut less thanupperTerm. There must be at least one term and either term may be null, in which case there is no bound on that side, but if there are two terms, both terms must be for the same field.
-
-
Method Detail
-
rewrite
public Query rewrite(IndexReader reader) throws java.io.IOException
Description copied from class:QueryExpert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
-
getField
public java.lang.String getField()
Returns the field name for this query
-
getLowerTerm
public Term getLowerTerm()
Returns the lower term of this range query
-
getUpperTerm
public Term getUpperTerm()
Returns the upper term of this range query
-
isInclusive
public boolean isInclusive()
Returnstrueif the range query is inclusive
-
toString
public java.lang.String toString(java.lang.String field)
Prints a user-readable version of this query.
-
equals
public boolean equals(java.lang.Object o)
Returns true iffois equal to this.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Returns a hash code value for this object.- Overrides:
hashCodein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG