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 boolean
DEFAULT_INCLUDE_LOWER
static boolean
DEFAULT_INCLUDE_UPPER
static ParseField
FROM_FIELD
static ParseField
GT_FIELD
static ParseField
GTE_FIELD
static ParseField
LT_FIELD
static ParseField
LTE_FIELD
static java.lang.String
NAME
static ParseField
TO_FIELD
Fields 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 boolean
doEquals(RangeQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
doHashCode()
protected QueryBuilder
doRewrite(QueryRewriteContext queryRewriteContext)
protected org.apache.lucene.search.Query
doToQuery(QueryShardContext context)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(XContentBuilder builder, ToXContent.Params params)
java.lang.String
fieldName()
Get the field name for this query.java.lang.String
format()
Gets the format field to parse the from/to fieldsRangeQueryBuilder
format(java.lang.String format)
In case of format field, we can parse the from/to fields using this time formatjava.lang.Object
from()
Gets the lower range value for this query.RangeQueryBuilder
from(java.lang.Object from)
The from part of the range query.RangeQueryBuilder
from(java.lang.Object from, boolean includeLower)
The from part of the range query.static RangeQueryBuilder
fromXContent(XContentParser parser)
protected MappedFieldType.Relation
getRelation(QueryRewriteContext queryRewriteContext)
java.lang.String
getWriteableName()
Returns the name of the writeable objectRangeQueryBuilder
gt(java.lang.Object from)
The from part of the range query.RangeQueryBuilder
gte(java.lang.Object from)
The from part of the range query.boolean
includeLower()
Gets the includeLower flag for this query.RangeQueryBuilder
includeLower(boolean includeLower)
Should the lower bound be included or not.boolean
includeUpper()
Gets the includeUpper flag for this query.RangeQueryBuilder
includeUpper(boolean includeUpper)
Should the upper bound be included or not.RangeQueryBuilder
lt(java.lang.Object to)
The to part of the range query.RangeQueryBuilder
lte(java.lang.Object to)
The to part of the range query.ShapeRelation
relation()
RangeQueryBuilder
relation(java.lang.String relation)
java.lang.String
timeZone()
In case of date field, gets the from/to fields timezone adjustmentRangeQueryBuilder
timeZone(java.lang.String timeZone)
In case of date field, we can adjust the from/to fields using a timezonejava.lang.Object
to()
Gets the upper range value for this query.RangeQueryBuilder
to(java.lang.Object to)
The to part of the range query.RangeQueryBuilder
to(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, writeTo
Methods 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:
doWriteTo
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
java.io.IOException
-
fieldName
public java.lang.String 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
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 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
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:
doXContent
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
java.io.IOException
-
fromXContent
- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String 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 java.io.IOException- Throws:
java.io.IOException
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException- Overrides:
doRewrite
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
java.io.IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException- Specified by:
doToQuery
in classAbstractQueryBuilder<RangeQueryBuilder>
- Throws:
java.io.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>
-