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.Params
-
Nested 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_FIELD-
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
-
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
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
All Methods Static Methods Instance Methods Concrete Methods 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, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQuery, toString, toXContent, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.index.query.QueryBuilder
boost, boost, getName, queryName, queryName, rewrite, toFilter, toQuery
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
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
public static final ParseField LTE_FIELD
-
GTE_FIELD
public static final ParseField GTE_FIELD
-
FROM_FIELD
public static final ParseField FROM_FIELD
-
TO_FIELD
public static final ParseField TO_FIELD
-
GT_FIELD
public static final ParseField GT_FIELD
-
LT_FIELD
public static final ParseField LT_FIELD
-
-
Constructor Detail
-
RangeQueryBuilder
public RangeQueryBuilder(java.lang.String fieldName)
A Query that matches documents within an range of terms.- Parameters:
fieldName- The field name
-
RangeQueryBuilder
public RangeQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- 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
public RangeQueryBuilder from(java.lang.Object from, boolean includeLower)
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
public RangeQueryBuilder from(java.lang.Object 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
public RangeQueryBuilder gt(java.lang.Object from)
The from part of the range query. Null indicates unbounded.
-
gte
public RangeQueryBuilder gte(java.lang.Object from)
The from part of the range query. Null indicates unbounded.
-
to
public RangeQueryBuilder to(java.lang.Object to, boolean includeUpper)
The to part of the range query. Null indicates unbounded.
-
to
public RangeQueryBuilder to(java.lang.Object 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
public RangeQueryBuilder lt(java.lang.Object to)
The to part of the range query. Null indicates unbounded.
-
lte
public RangeQueryBuilder lte(java.lang.Object to)
The to part of the range query. Null indicates unbounded.
-
includeLower
public RangeQueryBuilder includeLower(boolean includeLower)
Should the lower bound be included or not. Defaults totrue.
-
includeLower
public boolean includeLower()
Gets the includeLower flag for this query.
-
includeUpper
public RangeQueryBuilder includeUpper(boolean includeUpper)
Should the upper bound be included or not. Defaults totrue.
-
includeUpper
public boolean includeUpper()
Gets the includeUpper flag for this query.
-
timeZone
public RangeQueryBuilder timeZone(java.lang.String 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
public RangeQueryBuilder format(java.lang.String 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
public ShapeRelation relation()
-
relation
public RangeQueryBuilder relation(java.lang.String relation)
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContentin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static RangeQueryBuilder fromXContent(XContentParser parser) throws java.io.IOException
- 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
protected boolean doEquals(RangeQueryBuilder other)
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<RangeQueryBuilder>
-
-