Package org.apache.lucene.queries
Class CustomScoreQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.queries.CustomScoreQuery
-
- All Implemented Interfaces:
Cloneable
@Deprecated public class CustomScoreQuery extends Query implements Cloneable
Deprecated.Query that sets document score as a programmatic function of several (sub) scores:- the score of its subQuery (any query)
- (optional) the score of its
FunctionQuery
(or queries).
getCustomScoreProvider(org.apache.lucene.index.LeafReaderContext)
.- WARNING: This API is experimental and might change in incompatible ways in the next release.
- Clients should instead use FunctionScoreQuery. For simple multiplicative boosts, use
FunctionScoreQuery.boostByValue(Query, DoubleValuesSource)
. For more complex custom scores, use the lucene-expressions librarySimpleBindings bindings = new SimpleBindings(); bindings.add("score", DoubleValuesSource.SCORES); bindings.add("boost1", DoubleValuesSource.fromIntField("myboostfield")); bindings.add("boost2", DoubleValuesSource.fromIntField("myotherboostfield")); Expression expr = JavascriptCompiler.compile("score * (boost1 + ln(boost2))"); FunctionScoreQuery q = new FunctionScoreQuery(inputQuery, expr.getDoubleValuesSource(bindings));
-
-
Constructor Summary
Constructors Constructor Description CustomScoreQuery(Query subQuery)
Deprecated.Create a CustomScoreQuery over input subQuery.CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery)
Deprecated.Create a CustomScoreQuery over input subQuery and aFunctionQuery
.CustomScoreQuery(Query subQuery, FunctionQuery... scoringQueries)
Deprecated.Create a CustomScoreQuery over input subQuery and aFunctionQuery
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CustomScoreQuery
clone()
Deprecated.Weight
createWeight(IndexSearcher searcher, boolean needsScores, float boost)
Deprecated.boolean
equals(Object other)
Deprecated.Returns true ifo
is equal to this.protected CustomScoreProvider
getCustomScoreProvider(LeafReaderContext context)
Deprecated.Returns aCustomScoreProvider
that calculates the custom scores for the givenIndexReader
.Query[]
getScoringQueries()
Deprecated.The scoring queries that only affect the score of CustomScoreQuery.Query
getSubQuery()
Deprecated.The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match.int
hashCode()
Deprecated.Returns a hash code value for this object.String
name()
Deprecated.A short name of this query, used intoString(String)
.Query
rewrite(IndexReader reader)
Deprecated.String
toString(String field)
Deprecated.-
Methods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toString
-
-
-
-
Constructor Detail
-
CustomScoreQuery
public CustomScoreQuery(Query subQuery)
Deprecated.Create a CustomScoreQuery over input subQuery.- Parameters:
subQuery
- the sub query whose scored is being customized. Must not be null.
-
CustomScoreQuery
public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery)
Deprecated.Create a CustomScoreQuery over input subQuery and aFunctionQuery
.- Parameters:
subQuery
- the sub query whose score is being customized. Must not be null.scoringQuery
- a value source query whose scores are used in the custom score computation. This parameter is optional - it can be null.
-
CustomScoreQuery
public CustomScoreQuery(Query subQuery, FunctionQuery... scoringQueries)
Deprecated.Create a CustomScoreQuery over input subQuery and aFunctionQuery
.- Parameters:
subQuery
- the sub query whose score is being customized. Must not be null.scoringQueries
- value source queries whose scores are used in the custom score computation. This parameter is optional - it can be null or even an empty array.
-
-
Method Detail
-
rewrite
public Query rewrite(IndexReader reader) throws IOException
Deprecated.- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
clone
public CustomScoreQuery clone()
Deprecated.
-
equals
public boolean equals(Object other)
Deprecated.Returns true ifo
is equal to this.
-
hashCode
public int hashCode()
Deprecated.Returns a hash code value for this object.
-
getCustomScoreProvider
protected CustomScoreProvider getCustomScoreProvider(LeafReaderContext context) throws IOException
Deprecated.Returns aCustomScoreProvider
that calculates the custom scores for the givenIndexReader
. The default implementation returns a default implementation as specified in the docs ofCustomScoreProvider
.- Throws:
IOException
- Since:
- 2.9.2
-
createWeight
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException
Deprecated.- Overrides:
createWeight
in classQuery
- Throws:
IOException
-
getSubQuery
public Query getSubQuery()
Deprecated.The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match.
-
getScoringQueries
public Query[] getScoringQueries()
Deprecated.The scoring queries that only affect the score of CustomScoreQuery.
-
name
public String name()
Deprecated.A short name of this query, used intoString(String)
.
-
-