public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>> extends ToXContentToBytes implements QueryBuilder<QB>
Writeable.Reader<R>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
protected float |
boost |
static ParseField |
BOOST_FIELD |
static float |
DEFAULT_BOOST
Default for boost to apply to resulting Lucene query.
|
static ParseField |
NAME_FIELD |
protected java.lang.String |
queryName |
EMPTY_PARAMS
Modifier | Constructor and Description |
---|---|
protected |
AbstractQueryBuilder() |
Modifier and Type | Method and Description |
---|---|
protected QueryValidationException |
addValidationError(java.lang.String validationError,
QueryValidationException validationException) |
float |
boost()
Returns the boost for this query.
|
QB |
boost(float boost)
Sets the boost for this query.
|
protected static java.lang.Object |
convertToBytesRefIfString(java.lang.Object obj)
This helper method checks if the object passed in is a string, if so it
converts it to a
BytesRef . |
protected static java.lang.Object |
convertToStringIfBytesRef(java.lang.Object obj)
This helper method checks if the object passed in is a
BytesRef , if so it
converts it to a utf8 string. |
protected abstract boolean |
doEquals(QB other)
Indicates whether some other
QueryBuilder object of the same type is "equal to" this one. |
protected abstract int |
doHashCode() |
protected abstract QB |
doReadFrom(StreamInput in) |
protected QueryBuilder<?> |
doRewrite(QueryRewriteContext queryShardContext) |
protected abstract org.apache.lucene.search.Query |
doToQuery(QueryShardContext context) |
protected abstract void |
doWriteTo(StreamOutput out) |
protected abstract void |
doXContent(XContentBuilder builder,
ToXContent.Params params) |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getName()
Returns the name that identifies uniquely the query
|
int |
hashCode() |
protected void |
printBoostAndQueryName(XContentBuilder builder) |
java.lang.String |
queryName()
Returns the query name for the query.
|
QB |
queryName(java.lang.String queryName)
Sets the query name for the query.
|
QB |
readFrom(StreamInput in)
Reads an object of this type from the provided StreamInput.
|
protected java.util.List<QueryBuilder<?>> |
readQueries(StreamInput in) |
QueryBuilder<?> |
rewrite(QueryRewriteContext queryShardContext)
Rewrites this query builder into its primitive form.
|
org.apache.lucene.search.Query |
toFilter(QueryShardContext context)
Converts this QueryBuilder to an unscored lucene
Query that acts as a filter. |
protected static java.util.Collection<org.apache.lucene.search.Query> |
toQueries(java.util.Collection<QueryBuilder<?>> queryBuilders,
QueryShardContext context)
Helper method to convert collection of
QueryBuilder instances to lucene
Query instances. |
org.apache.lucene.search.Query |
toQuery(QueryShardContext context)
Converts this QueryBuilder to a lucene
Query . |
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
protected void |
writeQueries(StreamOutput out,
java.util.List<? extends QueryBuilder<?>> queries) |
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
buildAsBytes, buildAsBytes, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
rewriteQuery
getWriteableName
public static final float DEFAULT_BOOST
public static final ParseField NAME_FIELD
public static final ParseField BOOST_FIELD
protected java.lang.String queryName
protected float boost
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
protected abstract void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
protected void printBoostAndQueryName(XContentBuilder builder) throws java.io.IOException
java.io.IOException
public final org.apache.lucene.search.Query toQuery(QueryShardContext context) throws java.io.IOException
QueryBuilder
Query
.
Returns null if this query should be ignored in the context of
parent queries.toQuery
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
context
- additional information needed to construct the queriesQuery
or null if this query should be ignored upstreamjava.io.IOException
public final org.apache.lucene.search.Query toFilter(QueryShardContext context) throws java.io.IOException
QueryBuilder
Query
that acts as a filter.
Returns null if this query should be ignored in the context of
parent queries.toFilter
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
context
- additional information needed to construct the queriesQuery
or null if this query should be ignored upstreamjava.io.IOException
protected abstract org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
java.io.IOException
public final QB queryName(java.lang.String queryName)
queryName
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
public final java.lang.String queryName()
queryName
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
public final float boost()
boost
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
public final QB boost(float boost)
boost
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
public final QB readFrom(StreamInput in) throws java.io.IOException
StreamableReader
readFrom
in interface StreamableReader<QB extends AbstractQueryBuilder<QB>>
readFrom
in interface Writeable<QB extends AbstractQueryBuilder<QB>>
java.io.IOException
protected abstract QB doReadFrom(StreamInput in) throws java.io.IOException
java.io.IOException
public final void writeTo(StreamOutput out) throws java.io.IOException
Writeable
writeTo
in interface Writeable<QB extends AbstractQueryBuilder<QB>>
java.io.IOException
protected abstract void doWriteTo(StreamOutput out) throws java.io.IOException
java.io.IOException
protected final QueryValidationException addValidationError(java.lang.String validationError, QueryValidationException validationException)
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
protected abstract boolean doEquals(QB other)
QueryBuilder
object of the same type is "equal to" this one.public final int hashCode()
hashCode
in class java.lang.Object
protected abstract int doHashCode()
protected static java.lang.Object convertToBytesRefIfString(java.lang.Object obj)
BytesRef
.obj
- the input objectBytesRef
representation if input was of type stringprotected static java.lang.Object convertToStringIfBytesRef(java.lang.Object obj)
BytesRef
, if so it
converts it to a utf8 string.obj
- the input objectBytesRef
protected static java.util.Collection<org.apache.lucene.search.Query> toQueries(java.util.Collection<QueryBuilder<?>> queryBuilders, QueryShardContext context) throws QueryShardException, java.io.IOException
QueryBuilder
instances to lucene
Query
instances. QueryBuilder
that return null calling
their QueryBuilder.toQuery(QueryShardContext)
method are not added to the
resulting collection.QueryShardException
java.io.IOException
public java.lang.String getName()
QueryBuilder
getName
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
protected final void writeQueries(StreamOutput out, java.util.List<? extends QueryBuilder<?>> queries) throws java.io.IOException
java.io.IOException
protected final java.util.List<QueryBuilder<?>> readQueries(StreamInput in) throws java.io.IOException
java.io.IOException
public final QueryBuilder<?> rewrite(QueryRewriteContext queryShardContext) throws java.io.IOException
QueryBuilder
rewrite
in interface QueryBuilder<QB extends AbstractQueryBuilder<QB>>
java.io.IOException
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryShardContext) throws java.io.IOException
java.io.IOException