
- Lucene - Home
- Lucene - Overview
- Lucene - Environment Setup
- Lucene - First Application
- Lucene - Indexing Classes
- Lucene - Searching Classes
- Lucene - Indexing Process
- Lucene - Search Operation
- Lucene - Sorting
Lucene - Indexing Operations
- Lucene - Indexing Operations
- Lucene - Add Document
- Lucene - Update Document
- Lucene - Delete Document
- Lucene - Field Options
Lucene - Query Programming
- Lucene - Query Programming
- Lucene - TermQuery
- Lucene - TermRangeQuery
- Lucene - PrefixQuery
- Lucene - BooleanQuery
- Lucene - PhraseQuery
- Lucene - WildCardQuery
- Lucene - FuzzyQuery
- Lucene - MatchAllDocsQuery
- Lucene - MatchNoDocsQuery
- Lucene - RegexpQuery
Lucene - Analysis
- Lucene - Analysis
- Lucene - WhitespaceAnalyzer
- Lucene - SimpleAnalyzer
- Lucene - StopAnalyzer
- Lucene - StandardAnalyzer
- Lucene - KeywordAnalyzer
- Lucene - CustomAnalyzer
- Lucene - EnglishAnalyzer
- Lucene - FrenchAnalyzer
- Lucene - SpanishAnalyzer
Lucene - Resources
Lucene - IndexSearcher Class
This class acts as a core component which reads/searches indexes during the searching process.
Class Declaration
Following is the declaration for org.apache.lucene.search.IndexSearcher class −
public class IndexSearcher extends Searcher
Class Fields
Following table shows the class fields for IndexSearcher −
S.No. | Field & Description |
---|---|
1 |
protected final List<LeafReaderContext> leafContexts |
2 |
protected final IndexReaderContext readerContext |
Class Constructors
Following table shows the constructors for IndexSearcher −
S.No. | Field & Description |
---|---|
1 |
IndexSearcher(IndexReader r) Creates a searcher searching the provided index. |
2 |
IndexSearcher(IndexReaderContext context) Creates a searcher searching the provided top-level IndexReaderContext. |
3 |
IndexSearcher(IndexReaderContext context, Executor executor) Creates a searcher searching the provided top-level IndexReaderContext. |
4 |
IndexSearcher(IndexReader r, Executor executor) Runs searches for each segment separately, using the provided Executor. |
S.No. | Method & Description |
---|---|
1 |
CollectionStatistics collectionStatistics(String field) Returns CollectionStatistics for a field, or null if the field does not exist (has no indexed terms) |
2 |
int count(Query query) Count how many documents match the given query. |
3 |
Weight createWeight(Query query, ScoreMode scoreMode, float boost) Creates a Weight for the given query, potentially adding caching if possible and configured. |
4 |
Explanation explain(Query query, int doc) Returns an Explanation that describes how doc scored against query. |
5 |
protected Explanation explain(Weight weight, int doc) Expert: low-level implementation method Returns an Explanation that describes how doc scored against weight. |
6 |
static QueryCache getDefaultQueryCache() Expert: Get the default QueryCache or null if the cache is disabled. |
7 |
static QueryCachingPolicy getDefaultQueryCachingPolicy() Expert: Get the default QueryCachingPolicy. |
8 |
static Similarity getDefaultSimilarity() Expert: returns a default Similarity instance. |
9 |
IndexReader getIndexReader() Return the IndexReader this searches. |
10 |
List<LeafReaderContext> getLeafContexts() Expert: returns leaf contexts associated with this searcher. |
11 |
static int getMaxClauseCount() Return the maximum number of clauses permitted, 1024 by default. |
12 |
QueryCache getQueryCache() Return the query cache of this IndexSearcher. |
13 |
QueryCachingPolicy getQueryCachingPolicy() Return the query cache of this IndexSearcher. |
14 |
Similarity getSimilarity() Expert: Get the Similarity to use to compute scores. |
15 |
final IndexSearcher.LeafSlice[] getSlices() Returns the leaf slices used for concurrent searching. |
16 |
TaskExecutor getTaskExecutor() Returns the TaskExecutor that this searcher relies on to execute concurrent operations. |
17 |
QueryTimeout getTimeout() Get the configured QueryTimeout for all searches that run through this IndexSearcher, or null if not set. |
18 |
IndexReaderContext getTopReaderContext() Returns this searcher's top-level IndexReaderContext. |
19 |
Query rewrite(Query original) Expert: called to re-write queries into primitive queries. |
20 |
protected void search(IndexSearcher.LeafReaderContextPartition[] partitions, Weight weight, Collector collector) Lower-level search API. |
21 |
TopDocs search(Query query, int n) Finds the top n hits for query. |
22 |
TopFieldDocs search(Query query, int n, Sort sort) Search implementation with arbitrary sorting. |
23 |
TopFieldDocs search(Query query, int n, Sort sort, boolean doDocScores) Search implementation with arbitrary sorting, plus control over whether hit scores and max score should be computed. |
24 |
void search(Query query, Collector collector) Deprecated. This method is being deprecated in favor of search(Query, CollectorManager) due to its support for concurrency in IndexSearcher. |
25 |
<C extends Collector,T> T search(Query query, CollectorManager<C,T> collectorManager) Lower-level search API. |
26 |
TopDocs searchAfter(ScoreDoc after, Query query, int numHits) Finds the top n hits for query where all results are after a previous result (after). |
27 |
TopDocs searchAfter(ScoreDoc after, Query query, int n, Sort sort) Finds the top n hits for query where all results are after a previous result (after). |
28 |
TopFieldDocs searchAfter(ScoreDoc after, Query query, int numHits, Sort sort, boolean doDocScores) Finds the top n hits for query where all results are after a previous result (after), allowing control over whether hit scores and max score should be computed. |
29 |
protected void searchLeaf(LeafReaderContext ctx, int minDocId, int maxDocId, Weight weight, Collector collector) Lower-level search API |
30 |
static void setDefaultQueryCache(QueryCache defaultQueryCache) Expert: set the default QueryCache instance. |
31 |
static void setDefaultQueryCachingPolicy(QueryCachingPolicy defaultQueryCachingPolicy) Expert: set the default QueryCachingPolicy instance. |
32 |
static void setMaxClauseCount(int value) Set the maximum number of clauses permitted per Query. |
33 |
void setQueryCache(QueryCache queryCache) Set the QueryCache to use when scores are not needed. |
34 |
void setQueryCachingPolicy(QueryCachingPolicy queryCachingPolicy) Set the QueryCachingPolicy to use for query caching. |
35 |
void setSimilarity(Similarity similarity) Expert: Set the Similarity implementation used by this IndexSearcher. |
36 |
void setTimeout(QueryTimeout queryTimeout) Set a QueryTimeout for all searches that run through this IndexSearcher. |
37 |
protected IndexSearcher.LeafSlice[] slices(List<LeafReaderContext> leaves) Expert: Creates an array of leaf slices each holding a subset of the given leaves. |
38 |
static IndexSearcher.LeafSlice[] slices(List<LeafReaderContext> leaves, int maxDocsPerSlice, int maxSegmentsPerSlice, boolean allowSegmentPartitions) Static method to segregate LeafReaderContexts amongst multiple slices. |
39 |
StoredFields storedFields() Returns a StoredFields reader for the stored fields of this index. |
40 |
TermStatistics termStatistics(Term term, int docFreq, long totalTermFreq) Returns TermStatistics for a term. |
41 |
boolean timedOut() Returns true if any search hit the timeout. |
42 |
String toString() Returns string representation. |
Methods Inherited
This class inherits methods from the following classes −
- org.apache.lucene.search.Searcher
- java.lang.Object