Lucene - SPLessons

Lucene Indexing Classes

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

Lucene Indexing Classes

Lucene Indexing Classes

shape Description

A list is a think course of action of segments proposed to enable customers to discover information in a report. The route toward making a rundown is called requesting, and a man who does it is called an indexer. A file is a brief, strong, and particularly interconnected manual for the substance. It is a major gadget to getting to and coming back to content. It offers references to the zones of basic information and purposefully restricts references to unessential information. Ordering procedure is one of the inside convenience gave by Lucene. Taking after diagram speaks to the requesting system and usage of classes. IndexWriter is the most basic and focus part of the requesting technique. Taking after are the file classes.

shape Conceptual Figure

The following is the image for index processing. IndexWriter is a vital fragment which makes/overhauls records in the midst of requesting procedure. The Document containing Field to IndexWriter which explores the Document utilizing the Analyzer and after that makes/open/adjust records as required and store/redesign them in a Directory. IndexWriter is used to update or make records. It is not used to scrutinize records.

org.apache.lucene.index.IndexWriter

shape Description

IndexWriter is a very important segment which upgrades records amid ordering process. Following is the syntax declaration . [java]public class IndexWriter extends Object implements Closeable, TwoPhaseCommit[/java] Following are the various important methods of IndexWriter class.
Methods Description
void addDocument(Document doc) To add the document.
void addIndexes(Directory... dirs) To Add all sections from a variety of files into this index.
void close() Confers all progressions to a file and shuts all related documents.
void commit() To Commit every single pending change to the record.
void deleteAll() To delete the all reocrds from an index.
void forceMergeDeletes() Powers converging of all portions that have erased reports.

org.apache.lucene.store.Directory class

shape Description

Index class addresses the limit zone of the records and all things considered it is a summary of reports. These records are called document reports. Record reports are normally made once and a short time later used for read operation or can be eradicated. Taking after is the linguistic structure assertion of the Directory class. [java]public abstract class Directory extends Object implements Closeable[/java] Following are the various important methods of IndexWriter class.
Methods Description
void clearLock(String name) Endeavor to clear the lock.
void close() To close the store.
abstract void deleteFile(String name) To delete the already existed file.
abstract long fileLength(String name To get the length of the file.
String getLockID() To give back a string identifier that interestingly separates this Directory example from other Directory occurrences.
void sync(Collection names) Guarantee that any keeps in touch with these records are moved to stable cloud.

org.apache.lucene.analysis.Analyzer class

shape Description

Analyzer class is equipped for looking at a report and getting the tokens/words from the substance which is to be requested. With no examination done, IndexWriter can not make the record. Taking after is the linguistic structure revelation of the Analyzer class. [java]public abstract class Analyzer extends Object implements Closeable[/java] Following are the various important methods of Analyzer class.
Methods Description
void close() Liberates persistent assets utilized by this Analyzer.
int getOffsetGap(Fieldable field) Much the same as getPositionIncrementGap(java.lang.String), aside from Token balances.
protected Object getPreviousTokenStream() Utilized by Analyzers that actualize reusableTokenStream to recover beforehand spared TokenStreams for re-use by a similar string.
protected void setPreviousTokenStream(Object obj) Utilized by Analyzers that actualize reusableTokenStream to spare a TokenStream for later re-use by a similar threadg.

org.apache.lucene.document.Document Class

shape Description

Record addresses a virtual file with Fields where Field is an inquiry which can contain the physical report's substance, its meta data. Analyzer can appreciate a Document figuratively speaking. Taking after is the sentence structure presentation of the Document class. [java]public final class Document extends Object implements Serializable[/java] Following are the various important methods of Document class.
Methods Description
void clearLock(String name) Endeavor to clear the predefined lock.
String get(String name) Gives back the string estimation of the field with the given name if any exist in this archive, or invalid.
void add(Fieldable field) To add the field.
byte[][] getBinaryValues(String name) Gives back a variety of byte exhibits for of the fields that have the name indicated as the parameter of the method.
Fieldable getFieldable(String name) Gives back a field with the given name if any exist in this archive, or invalid.
void setBoost(float boost) Sets a boost factor for hits on any field of this record.
void removeFields(String name) Expels all fields with the given name from the report.

Summary

shape Key Points

  • An indexing process is one of the center usefulness gave by Lucene.
  • IndexWriter class is utilized to upgrade the index amid ordering process.
  • IndexSearcher is the most vital and center part of the seeking procedure.