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.
  • 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

      public static final org.elasticsearch.common.ParseField LTE_FIELD
    • GTE_FIELD

      public static final org.elasticsearch.common.ParseField GTE_FIELD
    • FROM_FIELD

      public static final org.elasticsearch.common.ParseField FROM_FIELD
    • TO_FIELD

      public static final org.elasticsearch.common.ParseField TO_FIELD
    • GT_FIELD

      public static final org.elasticsearch.common.ParseField GT_FIELD
    • LT_FIELD

      public static final org.elasticsearch.common.ParseField 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

      public RangeQueryBuilder​(StreamInput in) throws java.io.IOException
      Read from a stream.
      Throws:
      java.io.IOException
  • Method Details

    • doWriteTo

      protected void doWriteTo​(StreamOutput out) throws java.io.IOException
      Specified by:
      doWriteTo in class AbstractQueryBuilder<RangeQueryBuilder>
      Throws:
      java.io.IOException
    • fieldName

      public java.lang.String fieldName()
      Get the field name for this query.
      Specified by:
      fieldName in interface MultiTermQueryBuilder
    • 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 a BytesRef because in RangeQueryBuilder field are later parsed as BytesRef and 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 a BytesRef because in RangeQueryBuilder field are later parsed as BytesRef and 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 to true.
    • 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 to true.
    • 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​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      doXContent in class AbstractQueryBuilder<RangeQueryBuilder>
      Throws:
      java.io.IOException
    • fromXContent

      public static RangeQueryBuilder fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException
      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 interface NamedWriteable
    • 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 class AbstractQueryBuilder<RangeQueryBuilder>
      Throws:
      java.io.IOException
    • doToQuery

      protected org.apache.lucene.search.Query doToQuery​(SearchExecutionContext context) throws java.io.IOException
      Specified by:
      doToQuery in class AbstractQueryBuilder<RangeQueryBuilder>
      Throws:
      java.io.IOException
    • doHashCode

      protected int doHashCode()
      Specified by:
      doHashCode in class AbstractQueryBuilder<RangeQueryBuilder>
    • doEquals

      protected boolean doEquals​(RangeQueryBuilder other)
      Description copied from class: AbstractQueryBuilder
      Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
      Specified by:
      doEquals in class AbstractQueryBuilder<RangeQueryBuilder>