java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<RangeQueryBuilder>
org.elasticsearch.index.query.RangeQueryBuilder
- All Implemented Interfaces:
NamedWriteable,VersionedNamedWriteable,Writeable,MultiTermQueryBuilder,QueryBuilder,Rewriteable<QueryBuilder>,ToXContent,ToXContentObject
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.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
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final StringFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryNameFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionRangeQueryBuilder(String fieldName) A Query that matches documents within an range of terms.Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected QueryBuilderdoCoordinatorRewrite(CoordinatorRewriteContext coordinatorRewriteContext) protected booleandoEquals(RangeQueryBuilder other) Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intprotected QueryBuilderdoSearchRewrite(SearchExecutionContext searchExecutionContext) protected org.apache.lucene.search.QuerydoToQuery(SearchExecutionContext context) protected voiddoWriteTo(StreamOutput out) protected voiddoXContent(XContentBuilder builder, ToXContent.Params params) Get the field name for this query.format()Gets the format field to parse the from/to fieldsIn case of format field, we can parse the from/to fields using this time formatfrom()Gets the lower range value for this query.The from part of the range query.The from part of the range query.static RangeQueryBuilderfromXContent(XContentParser parser) The minimal version of the recipient this object can be sent toprotected MappedFieldType.RelationgetRelation(CoordinatorRewriteContext coordinatorRewriteContext) protected MappedFieldType.RelationgetRelation(SearchExecutionContext searchExecutionContext) Returns the name of the writeable objectThe from part of the range query.The from part of the range query.booleanGets the includeLower flag for this query.includeLower(boolean includeLower) Should the lower bound be included or not.booleanGets the includeUpper flag for this query.includeUpper(boolean includeUpper) Should the upper bound be included or not.The to part of the range query.The to part of the range query.relation()timeZone()In case of date field, gets the from/to fields timezone adjustmentIn case of date field, we can adjust the from/to fields using a timezoneto()Gets the upper range value for this query.The to part of the range query.The to part of the range query.Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, boostAndQueryNameToXContent, checkNegativeBoost, declareStandardFields, doIndexMetadataRewrite, doInnerHitsRewrite, doRewrite, equals, extractInnerHitBuilders, getMaxNestedDepth, getName, hashCode, parseInnerQueryBuilder, parseTopLevelQuery, parseTopLevelQuery, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, setMaxNestedDepth, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeQueries, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.index.query.QueryBuilder
boost, boost, getName, queryName, queryName, rewrite, toQueryMethods inherited from interface org.elasticsearch.xcontent.ToXContent
toXContentMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
DEFAULT_INCLUDE_UPPER
public static final boolean DEFAULT_INCLUDE_UPPER- See Also:
-
DEFAULT_INCLUDE_LOWER
public static final boolean DEFAULT_INCLUDE_LOWER- See Also:
-
LTE_FIELD
-
GTE_FIELD
-
GT_FIELD
-
LT_FIELD
-
-
Constructor Details
-
RangeQueryBuilder
A Query that matches documents within an range of terms.- Parameters:
fieldName- The field name
-
RangeQueryBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
IOException
-
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
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
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
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
Gets the format field to parse the from/to fields -
relation
-
relation
-
doXContent
- Specified by:
doXContentin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
getWriteableName
Description copied from interface:VersionedNamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable- Specified by:
getWriteableNamein interfaceVersionedNamedWriteable
-
getRelation
-
getRelation
protected MappedFieldType.Relation getRelation(SearchExecutionContext searchExecutionContext) throws IOException - Throws:
IOException
-
doCoordinatorRewrite
- Overrides:
doCoordinatorRewritein classAbstractQueryBuilder<RangeQueryBuilder>- Parameters:
coordinatorRewriteContext- AQueryRewriteContextthat enables limited rewrite capabilities happening on the coordinator node before execution moves to the data node.- Returns:
- A
QueryBuilderrepresenting the rewritten query which could be executed without going to the date node.
-
doSearchRewrite
protected QueryBuilder doSearchRewrite(SearchExecutionContext searchExecutionContext) throws IOException - Overrides:
doSearchRewritein classAbstractQueryBuilder<RangeQueryBuilder>- Parameters:
searchExecutionContext- AQueryRewriteContextthat enables full rewrite capabilities happening on the data node with all information available for rewriting.- Returns:
- A
QueryBuilderrepresenting the rewritten query. - Throws:
IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException - Specified by:
doToQueryin classAbstractQueryBuilder<RangeQueryBuilder>- Throws:
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>
-
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to- Specified by:
getMinimalSupportedVersionin interfaceVersionedNamedWriteable
-