Package org.elasticsearch.index.query
Class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
java.lang.Object
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 Object
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.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatstatic org.elasticsearch.common.xcontent.ParseFieldstatic floatDefault for boost to apply to resulting Lucene query.static org.elasticsearch.common.xcontent.ParseFieldprotected StringFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected QueryValidationExceptionaddValidationError(String validationError, QueryValidationException validationException)floatboost()Returns the boost for this query.boost(float boost)Sets the boost for this query.protected voidcheckNegativeBoost(float boost)protected static voiddeclareStandardFields(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends QueryBuilder,?> parser)Addsboostandquery_nameparsing to theAbstractObjectParserpassed in.protected abstract booleanIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected abstract intprotected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected abstract org.apache.lucene.search.QuerydoToQuery(SearchExecutionContext context)protected abstract voiddoWriteTo(StreamOutput out)protected abstract voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)booleanprotected voidextractInnerHitBuilders(Map<String,InnerHitContextBuilder> innerHits)For internal usage only! Extracts the inner hits from the query tree.getName()Returns the name that identifies uniquely the queryinthashCode()static QueryBuilderparseInnerQueryBuilder(org.elasticsearch.common.xcontent.XContentParser parser)Parses a query excluding the query element that wraps itstatic QueryBuilderparseInnerQueryBuilder(org.elasticsearch.common.xcontent.XContentParser parser, Integer nestedDepth)protected voidprintBoostAndQueryName(org.elasticsearch.common.xcontent.XContentBuilder builder)Returns the query name for the query.Sets the query name for the query.protected static <T> TrequireValue(T value, String message)rewrite(QueryRewriteContext queryRewriteContext)Rewrites this query builder into its primitive form.protected static voidthrowParsingExceptionOnMultipleFields(String queryName, org.elasticsearch.common.xcontent.XContentLocation contentLocation, String processedFieldName, String currentFieldName)org.apache.lucene.search.QuerytoQuery(SearchExecutionContext context)Converts this QueryBuilder to a luceneQuery.toString()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableNameMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
DEFAULT_BOOST
public static final float DEFAULT_BOOSTDefault 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
-
boost
protected float boost
-
-
Constructor Details
-
AbstractQueryBuilder
protected AbstractQueryBuilder() -
AbstractQueryBuilder
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
doWriteTo
- Throws:
IOException
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
IOException
-
doXContent
protected abstract void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Throws:
IOException
-
printBoostAndQueryName
protected void printBoostAndQueryName(org.elasticsearch.common.xcontent.XContentBuilder builder) throws IOException- Throws:
IOException
-
toQuery
public final org.apache.lucene.search.Query toQuery(SearchExecutionContext context) throws IOExceptionDescription copied from interface:QueryBuilderConverts this QueryBuilder to a luceneQuery. Returnsnullif this query should be ignored in the context of parent queries.- Specified by:
toQueryin interfaceQueryBuilder- Parameters:
context- additional information needed to construct the queries- Returns:
- the
Queryornullif this query should be ignored upstream - Throws:
IOException
-
doToQuery
protected abstract org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException- Throws:
IOException
-
queryName
Sets the query name for the query.- Specified by:
queryNamein interfaceQueryBuilder
-
queryName
Returns the query name for the query.- Specified by:
queryNamein interfaceQueryBuilder
-
boost
public final float boost()Returns the boost for this query.- Specified by:
boostin interfaceQueryBuilder
-
checkNegativeBoost
protected final void checkNegativeBoost(float boost) -
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:
boostin interfaceQueryBuilder
-
addValidationError
protected final QueryValidationException addValidationError(String validationError, QueryValidationException validationException) -
equals
-
doEquals
Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one. -
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode() -
getName
Description copied from interface:QueryBuilderReturns the name that identifies uniquely the query- Specified by:
getNamein interfaceQueryBuilder
-
rewrite
Description copied from interface:QueryBuilderRewrites 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:
rewritein interfaceQueryBuilder- Specified by:
rewritein interfaceRewriteable<QB extends AbstractQueryBuilder<QB>>- Throws:
IOException
-
doRewrite
- Throws:
IOException
-
extractInnerHitBuilders
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 IOExceptionParses a query excluding the query element that wraps it- Throws:
IOException
-
parseInnerQueryBuilder
public static QueryBuilder parseInnerQueryBuilder(org.elasticsearch.common.xcontent.XContentParser parser, Integer nestedDepth) throws IOException- Throws:
IOException
-
requireValue
-
throwParsingExceptionOnMultipleFields
-
declareStandardFields
protected static void declareStandardFields(org.elasticsearch.common.xcontent.AbstractObjectParser<? extends QueryBuilder,?> parser)Addsboostandquery_nameparsing to theAbstractObjectParserpassed in. All query builders exceptMatchAllQueryBuilderandMatchNoneQueryBuildersupport these fields so they should use this method. -
toString
-