public final class BoostQuery extends Query
The boost query will not impact the documents that match this query, it will only be used to boost the score of documents that match both the boost query and the search query.
Modifier and Type | Class and Description |
---|---|
static class |
BoostQuery.Method
Enum for specifying the method to use for applying boosts to the score for a search query.
|
protected static class |
QueryComponent.Parameter
Linked list of parameters.
|
Modifier and Type | Field and Description |
---|---|
protected QueryComponent.Parameter |
parameters |
protected Query |
query
The search query.
|
boost, DEFAULT_PARAMETERS, IGNORE_PARAMETERS
ACL, ACRONYMS, ACRONYMS_EXPANDED, ACRONYMS_ORIGINAL, ALIAS, ALLOW, ANONYMOUS, BOOST, BOOST_FREQUENCY, BOOST_POSITION, BOOST_PROXIMITY, COMPLETENESS_BOOST, DEFAULT_BOOST, DEFAULT_DEPTH, DEFAULT_FIELD_NORMS, DEFAULT_FUZZY_MAX_TERMS, DEFAULT_MINIMUM, DEFAULT_QUOTED, DEFAULT_RECURSIVE, DEFAULT_ROLLUP_LIMIT, DEFAULT_SCORE_DEPTH, DEFAULT_SCORE_EXPLAIN, DEFAULT_SEARCH_FIELD, DEFAULT_SIMILARITY, DEFAULT_SPAN, DENY, DEPTH, DISABLE_COORD, DISTANCE, FACET, FIELD_NORMS, FUZZY_MAX_TERMS, LANGUAGE, LOWER, METHOD, MINIMUM, ON, ORDER, QUERY, QUERY_LANGUAGE, QUOTED, RECURSIVE, RELEVANCY_MODEL, ROLLUP, SCORE_DEPTH, SCORE_EXPLAIN, SCORE_FUNCTIONS, SCORE_MODE, SIMILARITY, SIMILARITY_PREFIX, SOUNDS_LIKE, SPAN, SPELLCHECK_CORRECTED, SPELLCHECK_EXPANDED, SPELLCHECK_MODE, SPELLCHECK_ORIGINAL, SPELLCHECK_SUGGESTIONS, STOPWORDS, SYNONYMS, SYNONYMS_EXPANDED, SYNONYMS_ORIGINAL, TOKENIZE, UNSECURED_ZONES, UPPER, WARNING, WILDCARD, XON
Constructor and Description |
---|
BoostQuery() |
BoostQuery(Query query) |
BoostQuery(Query query,
FieldExpression... scoreFunctions) |
BoostQuery(Query query,
List<FieldExpression> scoreFunctions) |
BoostQuery(Query query,
Query boostQuery) |
BoostQuery(Query query,
Query boostQuery,
FieldExpression... scoreFunctions) |
BoostQuery(Query query,
Query boostQuery,
List<FieldExpression> scoreFunctions) |
Modifier and Type | Method and Description |
---|---|
protected static void |
addParameter(StringBuilder buffer,
String name,
Object value)
Add "\"
name \"=\"value \"" to buffer . |
void |
addScoreFunction(FieldExpression value)
Add a ScoreFunction to this BoostQuery.
|
protected static void |
appendParameter(StringBuilder buffer,
String name,
Object value)
Add ", \"
name \"=\"value \"" to buffer . |
BoostQuery |
clone()
Returns a deep copy of this Query instance.
|
boolean |
containsParameter(String name)
Returns true if the specified parameter exists for this Query object.
|
protected boolean |
equals(Object other,
Map<String,Object> defaults,
Set<String> ignore)
Checks whether
query equals this Query object. |
protected static void |
escape(StringBuilder buffer,
Object value) |
protected void |
escape(StringBuilder buffer,
String value,
boolean quote)
Helper method to escape a string for toString() .
|
Query |
getBoostQuery()
Get the boost query.
|
Query |
getFirstNode(QueryHandler selector)
Get the first query in the tree that has
parameter set to value . |
BoostQuery.Method |
getMethod()
Get the method for applying boosts to the search query's score.
|
protected void |
getNodes(List<Query> nodes,
QueryHandler selector)
Internal method to collect all nodes that have
parameter set to value . |
Object |
getParameter(String name)
Returns a named property for this Query object.
|
boolean |
getParameter(String name,
boolean defaultValue)
Gets a boolean parameter.
|
double |
getParameter(String name,
double defaultValue)
Gets a double parameter.
|
float |
getParameter(String name,
float defaultValue)
Gets a float parameter.
|
int |
getParameter(String name,
int defaultValue)
Gets an integer parameter.
|
long |
getParameter(String name,
long defaultValue)
Gets a long parameter.
|
Object |
getParameter(String name,
Object defaultValue)
Gets a parameter.
|
String |
getParameter(String name,
String defaultValue)
Gets a String parameter.
|
Query |
getQuery()
Get the search query.
|
FieldExpression[] |
getScoreFunctions()
Get the ScoreFunctions to use for boosting
AbstractFilterQuery.getQuery() . |
int |
hashCode() |
protected static StringBuilder |
indent(StringBuilder buffer,
int indent)
Support method to indent a "line" in a StringBuilder.
|
protected boolean |
isAllowNull()
Are null sub queries allowed.
|
Query |
optimize()
Optimizes this query object, removing unnecessary levels of expressions.
|
Iterator<Map.Entry<String,Object>> |
parameters()
Get an iterator for returning all custom parameters.
|
protected static int |
parseIntParameter(Object value,
int defaultValue) |
String |
prettyFormat()
Returns a hierarchical representation of this query as a string.
|
protected void |
prettyFormat(StringBuilder buffer,
int indent)
Pretty format all parameters for this Query instance.
|
void |
prettyPrint()
Sends a hierarchical representation of this query to standard out.
|
void |
prettyPrint(PrintStream out)
Sends a hierarchical representation of this query specified PrintStream.
|
Object |
removeParameter(String name)
Remove the value for a parameter for this Query object.
|
Query |
rewrite(QueryHandler handler)
Recursively rewrite this query using
handler . |
void |
rewriteChildren(QueryHandler handler)
Rewrite child nodes using
handler . |
protected void |
setBooleanParameter(String key,
Object value)
Internal method for setting a boolean parameter.
|
void |
setBoostQuery(List<Query> value)
Set the boost query.
|
void |
setBoostQuery(Query value)
Set the boost query.
|
protected void |
setEnumParameter(String key,
Object value,
String... enumValues)
Internal method for setting an object parameter.
|
protected void |
setIntegerParameter(String key,
Object value)
Internal method for setting an integer parameter.
|
void |
setMethod(BoostQuery.Method method)
Set the method for applying boosts to the search query's score.
|
void |
setParameter(String name,
Object value) |
void |
setParameters(Map<String,Object> value) |
void |
setParameters(Map<String,Object> params,
boolean override)
Copies parameters from a Map into this Query.
|
void |
setQuery(Query value)
Set the search query.
|
void |
setQuery(String term)
Set the search query to be a search for
term . |
protected void |
setRollupParameter(String key,
Object value) |
void |
setScoreFunctions(FieldExpression... value)
Set the ScoreFunctions to use for boosting
AbstractFilterQuery.getQuery() . |
void |
setScoreFunctions(List<FieldExpression> value)
Set the ScoreFunctions to use for boosting
AbstractFilterQuery.getQuery() . |
protected void |
setStringParameter(String key,
Object value)
Internal method for setting a string parameter.
|
protected void |
setUnsignedParameter(String key,
Object value)
Internal method for setting an integer parameter.
|
String |
toString() |
String |
toString(boolean compact) |
protected void |
toString(StringBuilder buffer,
boolean compact)
Write the String representation of this query to
buffer . |
addParameters, appendParameters, containsParameters, equals, equals, equals, getBoost, getInternalParameter, getLocale, getNodes, getQueryLanguage, getQueryString, isCompactParameter, prettyFormatParameters, setBoost, setBoost, setLocale, setParameters, setParameters
protected Query query
protected QueryComponent.Parameter parameters
public BoostQuery()
public BoostQuery(Query query)
public BoostQuery(Query query, FieldExpression... scoreFunctions)
public BoostQuery(Query query, List<FieldExpression> scoreFunctions)
public BoostQuery(Query query, Query boostQuery, FieldExpression... scoreFunctions)
public BoostQuery(Query query, Query boostQuery, List<FieldExpression> scoreFunctions)
public void setParameter(String name, Object value)
setParameter
in class Query
public Query getBoostQuery()
public void setBoostQuery(Query value)
public FieldExpression[] getScoreFunctions()
AbstractFilterQuery.getQuery()
.public void setScoreFunctions(List<FieldExpression> value)
AbstractFilterQuery.getQuery()
.public void setScoreFunctions(FieldExpression... value)
AbstractFilterQuery.getQuery()
.public void addScoreFunction(FieldExpression value)
public BoostQuery.Method getMethod()
public void setMethod(BoostQuery.Method method)
public Query getFirstNode(QueryHandler selector)
parameter
set to value
.
WARNING: this is an experimental API and may change in the near future.
selector
, or null
if no match found.protected void getNodes(List<Query> nodes, QueryHandler selector)
parameter
set to value
.public Query rewrite(QueryHandler handler)
handler
.public void rewriteChildren(QueryHandler handler)
handler
.public Query optimize()
protected void toString(StringBuilder buffer, boolean compact)
buffer
.protected void prettyFormat(StringBuilder buffer, int indent)
buffer
- buffer to write pretty formated parameters to.indent
- the indentation levelpublic int hashCode()
protected boolean equals(Object other, Map<String,Object> defaults, Set<String> ignore)
query
equals this Query object.other
- the query to compare todefaults
- map of default values for query parametersignore
- set of query parameters to ignore during equality check.public BoostQuery clone()
NOTE: values for parameters are shallow copied.
protected boolean isAllowNull()
public Query getQuery()
public void setQuery(Query value)
public void setQuery(String term)
term
.public Iterator<Map.Entry<String,Object>> parameters()
public boolean containsParameter(String name)
name
- parameter name.public final Object getParameter(String name)
name
- parameter name.public final String getParameter(String name, String defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public final boolean getParameter(String name, boolean defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public final int getParameter(String name, int defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public final long getParameter(String name, long defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public final float getParameter(String name, float defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public final double getParameter(String name, double defaultValue)
name
- parameter name.defaultValue
- default value to return if not set.public Object getParameter(String name, Object defaultValue)
name
- name of parameter to return.defaultValue
- default value to return if not set.public void setParameters(Map<String,Object> params, boolean override)
params
- the parameters to copy into this Query instance.override
- indicates if parameters from params should overwrite existing parameters in this Queryprotected static int parseIntParameter(Object value, int defaultValue)
public Object removeParameter(String name)
name
- the parameter to remove.protected final void setEnumParameter(String key, Object value, String... enumValues)
NOTE: enumValues must contain lower case strings.
protected final void setStringParameter(String key, Object value)
protected final void setIntegerParameter(String key, Object value)
protected final void setUnsignedParameter(String key, Object value)
protected final void setBooleanParameter(String key, Object value)
protected static void appendParameter(StringBuilder buffer, String name, Object value)
name
\"=\"value
\"" to buffer
.protected static void addParameter(StringBuilder buffer, String name, Object value)
name
\"=\"value
\"" to buffer
.protected static void escape(StringBuilder buffer, Object value)
protected void escape(StringBuilder buffer, String value, boolean quote)
buffer
- buffer to write escaped value tovalue
- the value to escapequote
- if true, escaped value will be wrapped in double quotes.public final String toString(boolean compact)
public final void prettyPrint()
public final void prettyPrint(PrintStream out)
out
- stream to output query representation topublic final String prettyFormat()
protected static StringBuilder indent(StringBuilder buffer, int indent)
Copyright © 2018 Attivio, Inc. All Rights Reserved.
PATENT NOTICE: Attivio, Inc. Software Related Patents. With respect to the Attivio software product(s) being used, the following patents apply: Querying Joined Data Within A Search Engine Index: United States Patent No.(s): 8,073,840. Ordered Processing of Groups of Messages: U.S. Patent No.(s) 8,495,656. Signal processing approach to sentiment analysis for entities in documents: U.S. Patent No.(s) 8,725,494. Other U.S. and International Patents Pending.