public class CustomScoreQuery extends Query implements java.lang.Cloneable
FunctionQuery
(or queries).getCustomScoreProvider(org.apache.lucene.index.LeafReaderContext)
.Modifier and Type | Class and Description |
---|---|
private static class |
CustomScoreQuery.CustomScorer
A scorer that applies a (callback) function on scores of the subQuery.
|
private class |
CustomScoreQuery.CustomWeight |
Modifier and Type | Field and Description |
---|---|
private Query[] |
scoringQueries |
private Query |
subQuery |
Constructor and Description |
---|
CustomScoreQuery(Query subQuery)
Create a CustomScoreQuery over input subQuery.
|
CustomScoreQuery(Query subQuery,
FunctionQuery... scoringQueries)
Create a CustomScoreQuery over input subQuery and a
FunctionQuery . |
CustomScoreQuery(Query subQuery,
FunctionQuery scoringQuery)
Create a CustomScoreQuery over input subQuery and a
FunctionQuery . |
Modifier and Type | Method and Description |
---|---|
CustomScoreQuery |
clone() |
Weight |
createWeight(IndexSearcher searcher,
boolean needsScores,
float boost)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(java.lang.Object other)
Returns true if
o is equal to this. |
private boolean |
equalsTo(CustomScoreQuery other) |
protected CustomScoreProvider |
getCustomScoreProvider(LeafReaderContext context)
Returns a
CustomScoreProvider that calculates the custom scores
for the given IndexReader . |
Query[] |
getScoringQueries()
The scoring queries that only affect the score of CustomScoreQuery.
|
Query |
getSubQuery()
The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match.
|
int |
hashCode()
Returns a hash code value for this object.
|
java.lang.String |
name()
A short name of this query, used in
toString(String) . |
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
java.lang.String |
toString(java.lang.String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
classHash, sameClassAs, toString
public CustomScoreQuery(Query subQuery)
subQuery
- the sub query whose scored is being customized. Must not be null.public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery)
FunctionQuery
.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.public CustomScoreQuery(Query subQuery, FunctionQuery... scoringQueries)
FunctionQuery
.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.public Query rewrite(IndexReader reader) throws java.io.IOException
Query
public CustomScoreQuery clone()
clone
in class java.lang.Object
public java.lang.String toString(java.lang.String field)
Query
field
assumed to be the
default field and omitted.public boolean equals(java.lang.Object other)
o
is equal to this.equals
in class Query
Query.sameClassAs(Object)
,
Query.classHash()
private boolean equalsTo(CustomScoreQuery other)
public int hashCode()
hashCode
in class Query
Query.equals(Object)
protected CustomScoreProvider getCustomScoreProvider(LeafReaderContext context) throws java.io.IOException
CustomScoreProvider
that calculates the custom scores
for the given IndexReader
. The default implementation returns a default
implementation as specified in the docs of CustomScoreProvider
.java.io.IOException
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws java.io.IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
needsScores
- True if document scores (Scorer.score()
) or match
frequencies (Scorer.freq()
) are needed.boost
- The boost that is propagated by the parent queries.java.io.IOException
public Query getSubQuery()
public Query[] getScoringQueries()
public java.lang.String name()
toString(String)
.