Lucene - IndexSearcher


Advertisements


Introduction

This class acts as a core component which reads/searches indexes during searching process.

Class declaration

Following is the declaration for org.apache.lucene.search.IndexSearcher class:

public class IndexSearcher
   extends Searcher

Field

Following are the fields for org.apache.lucene.index.IndexWriter class:

  • protected int[] docStarts

  • protected IndexReader[] subReaders

  • protected IndexSearcher[] subSearchers

Class constructors

S.N.Constructor & Description
1

IndexSearcher(Directory path)

Deprecated. Use IndexSearcher(IndexReader) instead.

2

IndexSearcher(Directory path, boolean readOnly)

Deprecated. Use IndexSearcher(IndexReader) instead.

3

IndexSearcher(IndexReader r)

Creates a searcher searching the provided index.

4

IndexSearcher(IndexReader r, ExecutorService executor)

Runs searches for each segment separately, using the provided ExecutorService.

5

IndexSearcher(IndexReader reader, IndexReader[] subReaders, int[] docStarts)

Expert: directly specify the reader, subReaders and their docID starts.

6

IndexSearcher(IndexReader reader, IndexReader[] subReaders, int[] docStarts, ExecutorService executor)

Expert: directly specify the reader, subReaders and their docID starts, and an ExecutorService.

Class methods

S.N.Method & Description
1

void close()

Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearcher(IndexReader r).

2

Weight createNormalizedWeight(Query query)

Creates a normalized weight for a top-level Query.

3

Document doc(int docID)

Returns the stored fields of document i.

4

Document doc(int docID, FieldSelector fieldSelector)

Get the Document at the nth position.

5

int docFreq(Term term)

Returns total docFreq for this term.

6

Explanation explain(Query query, int doc)

Returns an Explanation that describes how doc scored against query.

7

Explanation explain(Weight weight, int doc)

Expert: low-level implementation method Returns an Explanation that describes how doc scored against weight.

8

protected void gatherSubReaders(List allSubReaders, IndexReader r)

9

IndexReader getIndexReader()

Return the IndexReader this searches.

10

Similarity getSimilarity()

Expert: Return the Similarity implementation used by this Searcher.

11

IndexReader[] getSubReaders()

Returns the atomic subReaders used by this searcher.

12

int maxDoc()

Expert: Returns one greater than the largest possible document number.

13

Query rewrite(Query original)

Expert: called to re-write queries into primitive queries.

14

void search(Query query, Collector results)

Lower-level search API.

15

void search(Query query, Filter filter, Collector results)

Lower-level search API.

16

TopDocs search(Query query, Filter filter, int n)

Finds the top n hits for query, applying filter if non-null.

17

TopFieldDocs search(Query query, Filter filter, int n, Sort sort)

Search implementation with arbitrary sorting.

18

TopDocs search(Query query, int n)

Finds the top n hits for query.

19

TopFieldDocs search(Query query, int n, Sort sort)

Search implementation with arbitrary sorting and no filter.

20

void search(Weight weight, Filter filter, Collector collector)

Lower-level search API.

21

TopDocs search(Weight weight, Filter filter, int nDocs)

Expert: Low-level search implementation.

22

TopFieldDocs search(Weight weight, Filter filter, int nDocs, Sort sort)

Expert: Low-level search implementation with arbitrary sorting.

23

protected TopFieldDocs search(Weight weight, Filter filter, int nDocs, Sort sort, boolean fillFields)

Just like search(Weight, Filter, int, Sort), but you choose whether or not the fields in the returned FieldDoc instances should be set by specifying fillFields.

24

protected TopDocs search(Weight weight, Filter filter, ScoreDoc after, int nDocs)

Expert: Low-level search implementation.

25

TopDocs searchAfter(ScoreDoc after, Query query, Filter filter, int n)

Finds the top n hits for query, applying filter if non-null, where all results are after a previous result (after).

26

TopDocs searchAfter(ScoreDoc after, Query query, int n)

Finds the top n hits for query where all results are after a previous result (after).

27

void setDefaultFieldSortScoring(boolean doTrackScores, boolean doMaxScore)

By default, no scores are computed when sorting by field (using search(Query,Filter,int,Sort)).

28

void setSimilarity(Similarity similarity)

Expert: Set the Similarity implementation used by this Searcher.

29

String toString()

Methods inherited

This class inherits methods from the following classes:

  • org.apache.lucene.search.Searcher

  • java.lang.Object


lucene_searching_classes.htm

Advertisements