|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.Query org.apache.lucene.search.function.CustomScoreQuery
public class CustomScoreQuery
Query that sets document score as a programmatic function of several (sub) scores:
FieldScoreQuery
getCustomScoreProvider(org.apache.lucene.index.IndexReader)
.
WARNING: The status of the search.function package is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.
Constructor Summary | |
---|---|
CustomScoreQuery(Query subQuery)
Create a CustomScoreQuery over input subQuery. |
|
CustomScoreQuery(Query subQuery,
ValueSourceQuery... valSrcQueries)
Create a CustomScoreQuery over input subQuery and a ValueSourceQuery . |
|
CustomScoreQuery(Query subQuery,
ValueSourceQuery valSrcQuery)
Create a CustomScoreQuery over input subQuery and a ValueSourceQuery . |
Method Summary | |
---|---|
Object |
clone()
Returns a clone of this query. |
Weight |
createWeight(Searcher searcher)
Expert: Constructs an appropriate Weight implementation for this query. |
Explanation |
customExplain(int doc,
Explanation subQueryExpl,
Explanation valSrcExpl)
Deprecated. Will be removed in Lucene 3.1. The doc is relative to the current reader, which is unknown to CustomScoreQuery when using per-segment search (since Lucene 2.9). Please override getCustomScoreProvider(org.apache.lucene.index.IndexReader) and return a subclass
of CustomScoreProvider for the given IndexReader . |
Explanation |
customExplain(int doc,
Explanation subQueryExpl,
Explanation[] valSrcExpls)
Deprecated. Will be removed in Lucene 3.1. The doc is relative to the current reader, which is unknown to CustomScoreQuery when using per-segment search (since Lucene 2.9). Please override getCustomScoreProvider(org.apache.lucene.index.IndexReader) and return a subclass
of CustomScoreProvider for the given IndexReader . |
float |
customScore(int doc,
float subQueryScore,
float valSrcScore)
Deprecated. Will be removed in Lucene 3.1. The doc is relative to the current reader, which is unknown to CustomScoreQuery when using per-segment search (since Lucene 2.9). Please override getCustomScoreProvider(org.apache.lucene.index.IndexReader) and return a subclass
of CustomScoreProvider for the given IndexReader . |
float |
customScore(int doc,
float subQueryScore,
float[] valSrcScores)
Deprecated. Will be removed in Lucene 3.1. The doc is relative to the current reader, which is unknown to CustomScoreQuery when using per-segment search (since Lucene 2.9). Please override getCustomScoreProvider(org.apache.lucene.index.IndexReader) and return a subclass
of CustomScoreProvider for the given IndexReader . |
boolean |
equals(Object o)
Returns true if o is equal to this. |
void |
extractTerms(Set<Term> terms)
Expert: adds all terms occurring in this query to the terms set. |
protected CustomScoreProvider |
getCustomScoreProvider(IndexReader reader)
Returns a CustomScoreProvider that calculates the custom scores
for the given IndexReader . |
int |
hashCode()
Returns a hash code value for this object. |
boolean |
isStrict()
Checks if this is strict custom scoring. |
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. |
void |
setStrict(boolean strict)
Set the strict mode of this query. |
String |
toString(String field)
Prints a query to a string, with field assumed to be the
default field and omitted. |
Methods inherited from class org.apache.lucene.search.Query |
---|
combine, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CustomScoreQuery(Query subQuery)
subQuery
- the sub query whose scored is being customed. Must not be null.public CustomScoreQuery(Query subQuery, ValueSourceQuery valSrcQuery)
ValueSourceQuery
.
subQuery
- the sub query whose score is being customized. Must not be null.valSrcQuery
- a value source query whose scores are used in the custom score
computation. For most simple/convenient use case this would be a
FieldScoreQuery
.
This parameter is optional - it can be null.public CustomScoreQuery(Query subQuery, ValueSourceQuery... valSrcQueries)
ValueSourceQuery
.
subQuery
- the sub query whose score is being customized. Must not be null.valSrcQueries
- value source queries whose scores are used in the custom score
computation. For most simple/convenient use case these would be
FieldScoreQueries
.
This parameter is optional - it can be null or even an empty array.Method Detail |
---|
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public void extractTerms(Set<Term> terms)
Query
rewritten
form.
extractTerms
in class Query
public Object clone()
Query
clone
in class Query
public String toString(String field)
Query
field
assumed to be the
default field and omitted.
The representation used is one that is supposed to be readable
by QueryParser
. However,
there are the following limitations:
toString
in class Query
public boolean equals(Object o)
o
is equal to this.
equals
in class Query
public int hashCode()
hashCode
in class Query
protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) throws 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
.
IOException
@Deprecated public float customScore(int doc, float subQueryScore, float[] valSrcScores)
getCustomScoreProvider(org.apache.lucene.index.IndexReader)
and return a subclass
of CustomScoreProvider
for the given IndexReader
.
CustomScoreProvider.customScore(int,float,float[])
@Deprecated public float customScore(int doc, float subQueryScore, float valSrcScore)
getCustomScoreProvider(org.apache.lucene.index.IndexReader)
and return a subclass
of CustomScoreProvider
for the given IndexReader
.
CustomScoreProvider.customScore(int,float,float)
@Deprecated public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
getCustomScoreProvider(org.apache.lucene.index.IndexReader)
and return a subclass
of CustomScoreProvider
for the given IndexReader
.
CustomScoreProvider.customExplain(int,Explanation,Explanation[])
@Deprecated public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
getCustomScoreProvider(org.apache.lucene.index.IndexReader)
and return a subclass
of CustomScoreProvider
for the given IndexReader
.
CustomScoreProvider.customExplain(int,Explanation,Explanation[])
public Weight createWeight(Searcher searcher) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
IOException
public boolean isStrict()
Note: only has effect when the ValueSource part is not null.
public void setStrict(boolean strict)
strict
- The strict mode to set.isStrict()
public String name()
toString(String)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |