Class FunctionScoreQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.queries.function.FunctionScoreQuery
A query that wraps another query, and uses a DoubleValuesSource to replace or modify the wrapped
query's score
If the DoubleValuesSource doesn't return a value for a particular document, then that document will be given a score of 0.
-
Constructor Summary
ConstructorDescriptionFunctionScoreQuery
(Query in, DoubleValuesSource source) Create a new FunctionScoreQuery -
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionScoreQuery
boostByQuery
(Query in, Query boostMatch, float boostValue) Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by a boost factor if the document being scored also matches a separate boosting query.static FunctionScoreQuery
boostByValue
(Query in, DoubleValuesSource boost) Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by the value of a DoubleValuesSource.createWeight
(IndexSearcher searcher, ScoreMode scoreMode, float boost) boolean
int
hashCode()
rewrite
(IndexReader reader) void
visit
(QueryVisitor visitor) Methods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toString
-
Constructor Details
-
FunctionScoreQuery
Create a new FunctionScoreQuery- Parameters:
in
- the query to wrapsource
- a source of scores
-
-
Method Details
-
getWrappedQuery
- Returns:
- the wrapped Query
-
getSource
- Returns:
- the underlying value source
-
boostByValue
Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by the value of a DoubleValuesSource.If the source has no value for a particular document, the score for that document is preserved as-is.
- Parameters:
in
- the query to boostboost
- aDoubleValuesSource
containing the boost values
-
boostByQuery
Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by a boost factor if the document being scored also matches a separate boosting query.Documents that do not match the boosting query have their scores preserved.
This may be used to 'demote' documents that match the boosting query, by passing in a boostValue between 0 and 1.
- Parameters:
in
- the query to boostboostMatch
- the boosting queryboostValue
- the amount to boost documents which match the boosting query
-
createWeight
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException - Overrides:
createWeight
in classQuery
- Throws:
IOException
-
rewrite
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
visit
-
toString
-
equals
-
hashCode
public int hashCode()
-