|
||||||||||
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.ConstantScoreQuery
public class ConstantScoreQuery
A query that wraps another query or a filter and simply returns a constant score equal to the query boost for every document that matches the filter or query. For queries it therefore simply strips of all scores and returns a constant one.
NOTE: if the wrapped filter is an instance of
CachingWrapperFilter
, you'll likely want to
enforce deletions in the filter (using either CachingWrapperFilter.DeletesMode.RECACHE
or CachingWrapperFilter.DeletesMode.DYNAMIC
).
Nested Class Summary | |
---|---|
protected class |
ConstantScoreQuery.ConstantScorer
|
protected class |
ConstantScoreQuery.ConstantWeight
|
Field Summary | |
---|---|
protected Filter |
filter
|
protected Query |
query
|
Constructor Summary | |
---|---|
ConstantScoreQuery(Filter filter)
Wraps a Filter as a Query. |
|
ConstantScoreQuery(Query query)
Strips off scores from the passed in Query. |
Method Summary | |
---|---|
Weight |
createWeight(Searcher searcher)
Expert: Constructs an appropriate Weight implementation for this query. |
boolean |
equals(Object o)
|
void |
extractTerms(Set<Term> terms)
Expert: adds all terms occurring in this query to the terms set. |
Filter |
getFilter()
Returns the encapsulated filter, returns null if a query is wrapped. |
Query |
getQuery()
Returns the encapsulated query, returns null if a filter is wrapped. |
int |
hashCode()
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries. |
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 |
---|
clone, combine, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Filter filter
protected final Query query
Constructor Detail |
---|
public ConstantScoreQuery(Query query)
public ConstantScoreQuery(Filter filter)
new ConstantScoreQuery(new QueryWrapperFilter(query))
, instead
use ConstantScoreQuery(Query)
!
Method Detail |
---|
public Filter getFilter()
null
if a query is wrapped.
public Query getQuery()
null
if a filter is wrapped.
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 Weight createWeight(Searcher searcher) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
IOException
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)
equals
in class Query
public int hashCode()
hashCode
in class Query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |