Package org.elasticsearch.index.query
Class RangeQueryBuilder
java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<RangeQueryBuilder>
org.elasticsearch.index.query.RangeQueryBuilder
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,MultiTermQueryBuilder,QueryBuilder,Rewriteable<QueryBuilder>
public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> implements MultiTermQueryBuilder
A Query that matches documents within an range of terms.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_INCLUDE_LOWERstatic booleanDEFAULT_INCLUDE_UPPERstatic ParseFieldFROM_FIELDstatic ParseFieldGT_FIELDstatic ParseFieldGTE_FIELDstatic ParseFieldLT_FIELDstatic ParseFieldLTE_FIELDstatic java.lang.StringNAMEstatic ParseFieldTO_FIELDFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName -
Constructor Summary
Constructors Constructor Description RangeQueryBuilder(java.lang.String fieldName)A Query that matches documents within an range of terms.RangeQueryBuilder(StreamInput in)Read from a stream. -
Method Summary
Modifier and Type Method Description protected booleandoEquals(RangeQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(XContentBuilder builder, ToXContent.Params params)java.lang.StringfieldName()Get the field name for this query.java.lang.Stringformat()Gets the format field to parse the from/to fieldsRangeQueryBuilderformat(java.lang.String format)In case of format field, we can parse the from/to fields using this time formatjava.lang.Objectfrom()Gets the lower range value for this query.RangeQueryBuilderfrom(java.lang.Object from)The from part of the range query.RangeQueryBuilderfrom(java.lang.Object from, boolean includeLower)The from part of the range query.static RangeQueryBuilderfromXContent(XContentParser parser)protected MappedFieldType.RelationgetRelation(QueryRewriteContext queryRewriteContext)java.lang.StringgetWriteableName()Returns the name of the writeable objectRangeQueryBuildergt(java.lang.Object from)The from part of the range query.RangeQueryBuildergte(java.lang.Object from)The from part of the range query.booleanincludeLower()Gets the includeLower flag for this query.RangeQueryBuilderincludeLower(boolean includeLower)Should the lower bound be included or not.booleanincludeUpper()Gets the includeUpper flag for this query.RangeQueryBuilderincludeUpper(boolean includeUpper)Should the upper bound be included or not.RangeQueryBuilderlt(java.lang.Object to)The to part of the range query.RangeQueryBuilderlte(java.lang.Object to)The to part of the range query.ShapeRelationrelation()RangeQueryBuilderrelation(java.lang.String relation)java.lang.StringtimeZone()In case of date field, gets the from/to fields timezone adjustmentRangeQueryBuildertimeZone(java.lang.String timeZone)In case of date field, we can adjust the from/to fields using a timezonejava.lang.Objectto()Gets the upper range value for this query.RangeQueryBuilderto(java.lang.Object to)The to part of the range query.RangeQueryBuilderto(java.lang.Object to, boolean includeUpper)The to part of the range query.Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
DEFAULT_INCLUDE_UPPER
public static final boolean DEFAULT_INCLUDE_UPPER- See Also:
- Constant Field Values
-
DEFAULT_INCLUDE_LOWER
public static final boolean DEFAULT_INCLUDE_LOWER- See Also:
- Constant Field Values
-
LTE_FIELD
-
GTE_FIELD
-
FROM_FIELD
-
TO_FIELD
-
GT_FIELD
-
LT_FIELD
-
-
Constructor Details
-
RangeQueryBuilder
public RangeQueryBuilder(java.lang.String fieldName)A Query that matches documents within an range of terms.- Parameters:
fieldName- The field name
-
RangeQueryBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()Get the field name for this query.- Specified by:
fieldNamein interfaceMultiTermQueryBuilder
-
from
The from part of the range query. Null indicates unbounded. In case lower bound is assigned to a string, we internally convert it to aBytesRefbecause inRangeQueryBuilderfield are later parsed asBytesRefand we need internal representation of query to be equal regardless of whether it was created from XContent or via Java API. -
from
The from part of the range query. Null indicates unbounded. -
from
public java.lang.Object from()Gets the lower range value for this query. -
gt
The from part of the range query. Null indicates unbounded. -
gte
The from part of the range query. Null indicates unbounded. -
to
The to part of the range query. Null indicates unbounded. -
to
The to part of the range query. Null indicates unbounded. -
to
public java.lang.Object to()Gets the upper range value for this query. In case upper bound is assigned to a string, we internally convert it to aBytesRefbecause inRangeQueryBuilderfield are later parsed asBytesRefand we need internal representation of query to be equal regardless of whether it was created from XContent or via Java API. -
lt
The to part of the range query. Null indicates unbounded. -
lte
The to part of the range query. Null indicates unbounded. -
includeLower
Should the lower bound be included or not. Defaults totrue. -
includeLower
public boolean includeLower()Gets the includeLower flag for this query. -
includeUpper
Should the upper bound be included or not. Defaults totrue. -
includeUpper
public boolean includeUpper()Gets the includeUpper flag for this query. -
timeZone
In case of date field, we can adjust the from/to fields using a timezone -
timeZone
public java.lang.String timeZone()In case of date field, gets the from/to fields timezone adjustment -
format
In case of format field, we can parse the from/to fields using this time format -
format
public java.lang.String format()Gets the format field to parse the from/to fields -
relation
-
relation
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException- Specified by:
doXContentin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable
-
getRelation
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws java.io.IOException- Throws:
java.io.IOException
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException- Overrides:
doRewritein classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
java.io.IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException- Specified by:
doToQueryin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCodein classAbstractQueryBuilder<RangeQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<RangeQueryBuilder>
-