Lucene - SPLessons

Lucene Searching Classes

Home > Lesson > Chapter 6
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Lucene Searching Classes

Lucene Searching Classes

shape Description

Seeking strategy is again one of the middle helpfulness gave by Lucene. Its stream resemble that of requesting methodology. The fundamental quest for Lucene can be made using taking after classes which can similarly be named as foundation classes for all chase related operations. IndexSearcher is the most imperative and focus fragment of the seeking technique. IndexSearcher will go about as a middle fragment which searcher records made in the midst of requesting procedure. Taking after are the set classes will be utilized as a part of looking system.

org.apache.lucene.search.IndexSearcher

shape Description

IndexSearcher goes about as a center part which seeks files amid searching procedure. Following are the various methods of IndexSearcher.
Methods Description
void close() IndexReader is not shut, if IndexSearcher was developed with IndexSearcher
Document doc(int docID) Gives back the put away fields of report i.
int docFreq(Term term) Gives back the put away fields of report i.
IndexReader getIndexReader() To return the IndexReader.
IndexReader[] getSubReaders() Gives back the subReaders utilized by this searcher.
int maxDoc() Returns one more prominent than the biggest conceivable record number.

org.apache.lucene.index.Term

shape Description

Term class is the most minimal unit of looking. Following are the various methods of Term class.
Methods Description
void addDocument(Document doc) To add the document
String field() Gives back the field of this term, an interned string.
String text() Gives back the text.
Term createTerm(String text) Enhanced development of new Terms by reusing same field as this Term - maintains a strategic distance from field.intern() overhead.

org.apache.lucene.search.Query

shape Description

Query is a hypothetical class and contains diverse utility methodologies and is the parent of an extensive variety of request that Lucene uses in the midst of interest get ready. Taking after are the different techniques for Query class.
Methods Description
Object clone() Gives back a clone of this query.
Weight createWeight(Searcher searcher) Develops a proper Weight usage for this query.
float getBoost() Gets the support for this statement.
Query rewrite(IndexReader reader) called to re-compose inquiries into primitive questions.

org.apache.lucene.search.TermQuery

shape Description

TermQuery is the most generally used request challenge and is the foundation of various personality boggling request that Lucene can make usage of. Following are the various methods of TermQuery.
Methods Description
void addDocument(Document doc) To add the document.
void extractTerms(Set terms) includes all terms happening in this inquiry to the terms set.
Term getTerm() Gives back the term of this query.
String toString(String field) Prints a client coherent variant of this query.
int hashCode() Gives back a hash code esteem for this protest.

org.apache.lucene.search.TopDocs

shape Description

TopDocs centers to the top N inquiry things which facilitates the interest criteria. It is straight forward holder of pointers to show reports which are the yield of a thing. Taking after are the different strategies for TopDocs.
Methods Description
getMaxScore() Gives back the greatest score esteem experienced.
void setMaxScore(float maxScore) Sets the greatest score esteem experienced.
static TopDocs merge(Sort sort, int topN, TopDocs[] shardHits) Gives back another TopDocs, containing topN comes about over the gave TopDocs, sorting by the predetermined Sort.

Summary

shape Key Points

  • All the classes will inherit the properties from java.lang.Object.
  • QueryParser class is used to parse the client entered contribution to lucene reasonable arrangement inquiry.