Class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>

org.elasticsearch.index.query.AbstractQueryBuilder<QB>
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>
Direct Known Subclasses:
AbstractGeometryQueryBuilder, BaseTermQueryBuilder, BoolQueryBuilder, BoostingQueryBuilder, CombinedFieldsQueryBuilder, CommonTermsQueryBuilder, ConstantScoreQueryBuilder, DisMaxQueryBuilder, DistanceFeatureQueryBuilder, ExistsQueryBuilder, FieldMaskingSpanQueryBuilder, FunctionScoreQueryBuilder, FuzzyQueryBuilder, GeoBoundingBoxQueryBuilder, GeoDistanceQueryBuilder, GeoPolygonQueryBuilder, IdsQueryBuilder, IntervalQueryBuilder, MatchAllQueryBuilder, MatchBoolPrefixQueryBuilder, MatchNoneQueryBuilder, MatchPhrasePrefixQueryBuilder, MatchPhraseQueryBuilder, MatchQueryBuilder, MoreLikeThisQueryBuilder, MultiMatchQueryBuilder, NestedQueryBuilder, PrefixQueryBuilder, QueryStringQueryBuilder, RangeQueryBuilder, RegexpQueryBuilder, ScriptQueryBuilder, ScriptScoreQueryBuilder, SimpleQueryStringBuilder, SpanContainingQueryBuilder, SpanFirstQueryBuilder, SpanMultiTermQueryBuilder, SpanNearQueryBuilder, SpanNotQueryBuilder, SpanOrQueryBuilder, SpanWithinQueryBuilder, TermsQueryBuilder, TermsSetQueryBuilder, TypeQueryBuilder, WildcardQueryBuilder, WrapperQueryBuilder

public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>> extends implements QueryBuilder
Base class for all classes producing lucene queries. Supports conversion to BytesReference and creation of lucene Query objects.
  • 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

    Fields
    Modifier and Type
    Field
    Description
    protected float
     
    static org.elasticsearch.common.xcontent.ParseField
     
    static float
    Default for boost to apply to resulting Lucene query.
    static org.elasticsearch.common.xcontent.ParseField
     
    protected
     

    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
    Modifier
    Constructor
    Description
    protected
     
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
     validationError, QueryValidationException validationException)
     
    float
    Returns the boost for this query.
    boost​(float boost)
    Sets the boost for this query.
    protected void
    checkNegativeBoost​(float boost)
     
    protected static void
    declareStandardFields​(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends QueryBuilder,​?> parser)
    Adds boost and query_name parsing to the AbstractObjectParser passed in.
    protected abstract boolean
    doEquals​(QB other)
    Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
    protected abstract int
     
    protected QueryBuilder
    doRewrite​(QueryRewriteContext queryRewriteContext)
     
    protected abstract org.apache.lucene.search.Query
     
    protected abstract void
     
    protected abstract void
    doXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    boolean
     obj)
     
    protected void
    <,​InnerHitContextBuilder> innerHits)
    For internal usage only! Extracts the inner hits from the query tree.
    Returns the name that identifies uniquely the query
    int
     
    parseInnerQueryBuilder​(org.elasticsearch.common.xcontent.XContentParser parser)
    Parses a query excluding the query element that wraps it
    parseInnerQueryBuilder​(org.elasticsearch.common.xcontent.XContentParser parser,  nestedDepth)
     
    protected void
    printBoostAndQueryName​(org.elasticsearch.common.xcontent.XContentBuilder builder)
     
    Returns the query name for the query.
     queryName)
    Sets the query name for the query.
    protected static <T> T
    requireValue​(T value,  message)
     
    rewrite​(QueryRewriteContext queryRewriteContext)
    Rewrites this query builder into its primitive form.
    protected static void
     queryName, org.elasticsearch.common.xcontent.XContentLocation contentLocation,  processedFieldName,  currentFieldName)
     
    org.apache.lucene.search.Query
    Converts this QueryBuilder to a lucene Query.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    void
    Write this into the StreamOutput.

    Methods inherited from class java.lang.

    , , , , , , ,

    Methods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable

    getWriteableName

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject

    isFragment
  • Field Details

    • DEFAULT_BOOST

      public static final float DEFAULT_BOOST
      Default for boost to apply to resulting Lucene query. Defaults to 1.0
      See Also:
      Constant Field Values
    • NAME_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField NAME_FIELD
    • BOOST_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField BOOST_FIELD
    • queryName

      protected  queryName
    • boost

      protected float boost
  • Constructor Details

    • AbstractQueryBuilder

      protected AbstractQueryBuilder()
    • AbstractQueryBuilder

      protected AbstractQueryBuilder(StreamInput in) throws
      Throws:
  • Method Details

    • writeTo

      public final void writeTo(StreamOutput out) throws
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
    • doWriteTo

      protected abstract void doWriteTo(StreamOutput out) throws
      Throws:
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
    • doXContent

      protected abstract void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      Throws:
    • printBoostAndQueryName

      protected void printBoostAndQueryName(org.elasticsearch.common.xcontent.XContentBuilder builder) throws
      Throws:
    • toQuery

      public final org.apache.lucene.search.Query toQuery(SearchExecutionContext context) throws
      Description copied from interface: QueryBuilder
      Converts this QueryBuilder to a lucene Query. Returns null if this query should be ignored in the context of parent queries.
      Specified by:
      toQuery in interface QueryBuilder
      Parameters:
      context - additional information needed to construct the queries
      Returns:
      the Query or null if this query should be ignored upstream
      Throws:
    • doToQuery

      protected abstract org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws
      Throws:
    • queryName

      public final  queryName)
      Sets the query name for the query.
      Specified by:
      queryName in interface QueryBuilder
    • queryName

      public final  queryName()
      Returns the query name for the query.
      Specified by:
      queryName in interface QueryBuilder
    • boost

      public final float boost()
      Returns the boost for this query.
      Specified by:
      boost in interface QueryBuilder
    • checkNegativeBoost

      protected final void checkNegativeBoost(float boost)
    • boost

      public final QB boost(float boost)
      Sets the boost for this query. Documents matching this query will (in addition to the normal weightings) have their score multiplied by the boost provided.
      Specified by:
      boost in interface QueryBuilder
    • addValidationError

      protected final  validationError, QueryValidationException validationException)
    • equals

      public final boolean equals( obj)
      Overrides:
       in class 
    • doEquals

      protected abstract boolean doEquals(QB other)
      Indicates whether some other QueryBuilder object of the same type is "equal to" this one.
    • hashCode

      public final int hashCode()
      Overrides:
       in class 
    • doHashCode

      protected abstract int doHashCode()
    • getName

      public  getName()
      Description copied from interface: QueryBuilder
      Returns the name that identifies uniquely the query
      Specified by:
      getName in interface QueryBuilder
    • rewrite

      public final QueryBuilder rewrite(QueryRewriteContext queryRewriteContext) throws
      Description copied from interface: QueryBuilder
      Rewrites this query builder into its primitive form. By default this method return the builder itself. If the builder did not change the identity reference must be returned otherwise the builder will be rewritten infinitely.
      Specified by:
      rewrite in interface QueryBuilder
      Specified by:
      rewrite in interface Rewriteable<QB extends AbstractQueryBuilder<QB>>
      Throws:
    • doRewrite

      protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws
      Throws:
    • extractInnerHitBuilders

      protected void extractInnerHitBuilders(<,​InnerHitContextBuilder> innerHits)
      For internal usage only! Extracts the inner hits from the query tree. While it extracts inner hits, child inner hits are inlined into the inner hit builder they belong to.
    • parseInnerQueryBuilder

      public static QueryBuilder parseInnerQueryBuilder(org.elasticsearch.common.xcontent.XContentParser parser) throws
      Parses a query excluding the query element that wraps it
      Throws:
    • parseInnerQueryBuilder

      public static QueryBuilder parseInnerQueryBuilder(org.elasticsearch.common.xcontent.XContentParser parser,  nestedDepth) throws
      Throws:
    • requireValue

      protected static <T> T requireValue(T value,  message)
    • throwParsingExceptionOnMultipleFields

      protected static void throwParsingExceptionOnMultipleFields( queryName, org.elasticsearch.common.xcontent.XContentLocation contentLocation,  processedFieldName,  currentFieldName)
    • declareStandardFields

      protected static void declareStandardFields(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends QueryBuilder,​?> parser)
      Adds boost and query_name parsing to the AbstractObjectParser passed in. All query builders except MatchAllQueryBuilder and MatchNoneQueryBuilder support these fields so they should use this method.
    • toString

      public final  toString()
      Overrides:
       in class