org.apache.lucene.search
public abstract class Searcher extends Object implements Searchable
Note that you can only access Hits from a Searcher as long as it is not yet closed, otherwise an IOException will be thrown.
Method Summary | |
---|---|
abstract void | close() |
protected Weight | createWeight(Query query)
creates a weight for query |
abstract Document | doc(int i) |
abstract int | docFreq(Term term) |
int[] | docFreqs(Term[] terms) |
Explanation | explain(Query query, int doc) Returns an Explanation that describes how doc scored against
query .
|
abstract Explanation | explain(Weight weight, int doc) |
Similarity | getSimilarity() Expert: Return the Similarity implementation used by this Searcher.
|
abstract int | maxDoc() |
abstract Query | rewrite(Query query) |
Hits | search(Query query) Returns the documents matching query . |
Hits | search(Query query, Filter filter) Returns the documents matching query and
filter . |
Hits | search(Query query, Sort sort) Returns documents matching query sorted by
sort . |
Hits | search(Query query, Filter filter, Sort sort) Returns documents matching query and filter ,
sorted by sort . |
TopFieldDocs | search(Query query, Filter filter, int n, Sort sort) Expert: Low-level search implementation with arbitrary sorting. |
void | search(Query query, HitCollector results) Lower-level search API.
|
void | search(Query query, Filter filter, HitCollector results) Lower-level search API.
|
TopDocs | search(Query query, Filter filter, int n) Expert: Low-level search implementation. |
abstract void | search(Weight weight, Filter filter, HitCollector results) |
abstract TopDocs | search(Weight weight, Filter filter, int n) |
abstract TopFieldDocs | search(Weight weight, Filter filter, int n, Sort sort) |
void | setSimilarity(Similarity similarity) Expert: Set the Similarity implementation used by this Searcher.
|
query
Returns: new weight
doc
scored against
query
.
This is intended to be used in developing Similarity implementations, and, for good performance, should not be displayed with every hit. Computing an explanation is as expensive as executing the query over the entire index.
This defaults to the current value of {@link Similarity#getDefault()}.
query
.Throws: BooleanQuery.TooManyClauses
query
and
filter
.Throws: BooleanQuery.TooManyClauses
query
sorted by
sort
.Throws: BooleanQuery.TooManyClauses
query
and filter
,
sorted by sort
.Throws: BooleanQuery.TooManyClauses
n
hits for query
, applying
filter
if non-null, and sorting the hits by the criteria in
sort
.
Applications should usually call {@link Searcher#search(Query,Filter,Sort)} instead.
Throws: BooleanQuery.TooManyClauses
{@link HitCollector#collect(int,float)} is called for every non-zero scoring document.
Applications should only use this if they need all of the matching documents. The high-level search API ({@link Searcher#search(Query)}) is usually more efficient, as it skips non-high-scoring hits.
Note: The score
passed to this method is a raw score.
In other words, the score will not necessarily be a float whose value is
between 0 and 1.
Throws: BooleanQuery.TooManyClauses
{@link HitCollector#collect(int,float)} is called for every non-zero
scoring document.
HitCollector-based access to remote indexes is discouraged.
Applications should only use this if they need all of the matching documents. The high-level search API ({@link Searcher#search(Query)}) is usually more efficient, as it skips non-high-scoring hits.
Parameters: query to match documents filter if non-null, a bitset used to eliminate some documents results to receive hits
Throws: BooleanQuery.TooManyClauses
n
hits for query
, applying filter
if non-null.
Called by {@link Hits}.
Applications should usually call {@link Searcher#search(Query)} or {@link Searcher#search(Query,Filter)} instead.
Throws: BooleanQuery.TooManyClauses
See Also: setDefault