Class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>

    • Field Detail

      • 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 ParseField NAME_FIELD
      • BOOST_FIELD

        public static final ParseField BOOST_FIELD
      • queryName

        protected java.lang.String queryName
      • boost

        protected float boost
    • Constructor Detail

      • AbstractQueryBuilder

        protected AbstractQueryBuilder()
      • AbstractQueryBuilder

        protected AbstractQueryBuilder​(StreamInput in)
                                throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • doWriteTo

        protected abstract void doWriteTo​(StreamOutput out)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • doXContent

        protected abstract void doXContent​(XContentBuilder builder,
                                           ToXContent.Params params)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • printBoostAndQueryName

        protected void printBoostAndQueryName​(XContentBuilder builder)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • toQuery

        public final org.apache.lucene.search.Query toQuery​(QueryShardContext context)
                                                     throws java.io.IOException
        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:
        java.io.IOException
      • toFilter

        public final org.apache.lucene.search.Query toFilter​(QueryShardContext context)
                                                      throws java.io.IOException
        Description copied from interface: QueryBuilder
        Converts this QueryBuilder to an unscored lucene Query that acts as a filter. Returns null if this query should be ignored in the context of parent queries.
        Specified by:
        toFilter 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:
        java.io.IOException
      • doToQuery

        protected abstract org.apache.lucene.search.Query doToQuery​(QueryShardContext context)
                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • queryName

        public final QB queryName​(java.lang.String queryName)
        Sets the query name for the query.
        Specified by:
        queryName in interface QueryBuilder
      • queryName

        public final java.lang.String 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
      • equals

        public final boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • 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:
        hashCode in class java.lang.Object
      • doHashCode

        protected abstract int doHashCode()
      • getName

        public java.lang.String 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 queryShardContext)
                                   throws java.io.IOException
        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:
        java.io.IOException
      • extractInnerHitBuilders

        protected void extractInnerHitBuilders​(java.util.Map<java.lang.String,​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​(XContentParser parser)
                                                   throws java.io.IOException
        Parses a query excluding the query element that wraps it
        Throws:
        java.io.IOException
      • requireValue

        protected static <T> T requireValue​(T value,
                                            java.lang.String message)
      • throwParsingExceptionOnMultipleFields

        protected static void throwParsingExceptionOnMultipleFields​(java.lang.String queryName,
                                                                    XContentLocation contentLocation,
                                                                    java.lang.String processedFieldName,
                                                                    java.lang.String currentFieldName)
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public final java.lang.String toString​(boolean pretty)