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
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.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
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
static boolean
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static org.elasticsearch.common.xcontent.ParseField
static String
static org.elasticsearch.common.xcontent.ParseField
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
ConstructorDescriptionRangeQueryBuilder(String fieldName)
A Query that matches documents within an range of terms.Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
doEquals(RangeQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
protected QueryBuilder
doRewrite(QueryRewriteContext queryRewriteContext)
protected org.apache.lucene.search.Query
doToQuery(SearchExecutionContext context)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.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 RangeQueryBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
protected MappedFieldType.Relation
getRelation(QueryRewriteContext queryRewriteContext)
Returns the name of the writeable objectThe from part of the range query.The from part of the range query.boolean
Gets the includeLower flag for this query.includeLower(boolean includeLower)
Should the lower bound be included or not.boolean
Gets 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, checkNegativeBoost, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, 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, toQuery
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
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 org.elasticsearch.common.xcontent.ParseField LTE_FIELD -
GTE_FIELD
public static final org.elasticsearch.common.xcontent.ParseField GTE_FIELD -
FROM_FIELD
public static final org.elasticsearch.common.xcontent.ParseField FROM_FIELD -
TO_FIELD
public static final org.elasticsearch.common.xcontent.ParseField TO_FIELD -
GT_FIELD
public static final org.elasticsearch.common.xcontent.ParseField GT_FIELD -
LT_FIELD
public static final org.elasticsearch.common.xcontent.ParseField 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:
doWriteTo
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
IOException
-
fieldName
Get the field name for this query.- Specified by:
fieldName
in 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 aBytesRef
because inRangeQueryBuilder
field are later parsed asBytesRef
and 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 aBytesRef
because inRangeQueryBuilder
field are later parsed asBytesRef
and 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
protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
doXContent
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
IOException
-
fromXContent
public static RangeQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
getWriteableName
Description copied from interface:NamedWriteable
Returns the name of the writeable object- Specified by:
getWriteableName
in interfaceNamedWriteable
-
getRelation
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException- Throws:
IOException
-
doRewrite
- Overrides:
doRewrite
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException- Specified by:
doToQuery
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCode
in classAbstractQueryBuilder<RangeQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<RangeQueryBuilder>
-