Class IndexToolsImpl
- java.lang.Object
-
- org.apache.lucene.luke.models.LukeModel
-
- org.apache.lucene.luke.models.tools.IndexToolsImpl
-
- All Implemented Interfaces:
IndexTools
public final class IndexToolsImpl extends LukeModel implements IndexTools
Default implementation ofIndexTools
-
-
Constructor Summary
Constructors Constructor Description IndexToolsImpl(IndexReader reader, boolean useCompound, boolean keepAllCommits)Constructs an IndexToolsImpl that holds givenIndexReader.IndexToolsImpl(Directory dir, boolean useCompound, boolean keepAllCommits)Constructs an IndexToolsImpl that holds givenDirectory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocument(Document doc, Analyzer analyzer)Add new document to this index.CheckIndex.StatuscheckIndex(PrintStream ps)Check the current index status.voidcreateNewIndex()Create a new index.voidcreateNewIndex(String dataDir)Create a new index with sample documents.voiddeleteDocuments(Query query)Delete documents from this index by the specified query.StringexportTerms(String destDir, String field, String delimiter)Export terms from given field into a new file on the destination directoryvoidoptimize(boolean expunge, int maxNumSegments, PrintStream ps)Execute force merges.voidrepairIndex(CheckIndex.Status st, PrintStream ps)Try to repair the corrupted index using previously returned index status.-
Methods inherited from class org.apache.lucene.luke.models.LukeModel
getFieldNames
-
-
-
-
Constructor Detail
-
IndexToolsImpl
public IndexToolsImpl(Directory dir, boolean useCompound, boolean keepAllCommits)
Constructs an IndexToolsImpl that holds givenDirectory.- Parameters:
dir- - the index directoryuseCompound- - if true, compound file format is usedkeepAllCommits- - if true, all commit points are reserved
-
IndexToolsImpl
public IndexToolsImpl(IndexReader reader, boolean useCompound, boolean keepAllCommits)
Constructs an IndexToolsImpl that holds givenIndexReader.- Parameters:
reader- - the index readeruseCompound- - if true, compound file format is usedkeepAllCommits- - if true, all commit points are reserved
-
-
Method Detail
-
optimize
public void optimize(boolean expunge, int maxNumSegments, PrintStream ps)Description copied from interface:IndexToolsExecute force merges.Merges are executed until there are maxNumSegments segments.
When expunge is true, maxNumSegments parameter is ignored.- Specified by:
optimizein interfaceIndexTools- Parameters:
expunge- - if true, only segments having deleted documents are mergedmaxNumSegments- - max number of segmentsps- - information stream
-
checkIndex
public CheckIndex.Status checkIndex(PrintStream ps)
Description copied from interface:IndexToolsCheck the current index status.- Specified by:
checkIndexin interfaceIndexTools- Parameters:
ps- information stream- Returns:
- index status
-
repairIndex
public void repairIndex(CheckIndex.Status st, PrintStream ps)
Description copied from interface:IndexToolsTry to repair the corrupted index using previously returned index status.This method must be called with the return value from
IndexTools.checkIndex(PrintStream).- Specified by:
repairIndexin interfaceIndexTools- Parameters:
st- - index statusps- - information stream
-
addDocument
public void addDocument(Document doc, Analyzer analyzer)
Description copied from interface:IndexToolsAdd new document to this index.- Specified by:
addDocumentin interfaceIndexTools- Parameters:
doc- - document to be addedanalyzer- - analyzer for parsing to document
-
deleteDocuments
public void deleteDocuments(Query query)
Description copied from interface:IndexToolsDelete documents from this index by the specified query.- Specified by:
deleteDocumentsin interfaceIndexTools- Parameters:
query- - query for deleting
-
createNewIndex
public void createNewIndex()
Description copied from interface:IndexToolsCreate a new index.- Specified by:
createNewIndexin interfaceIndexTools
-
createNewIndex
public void createNewIndex(String dataDir)
Description copied from interface:IndexToolsCreate a new index with sample documents.- Specified by:
createNewIndexin interfaceIndexTools- Parameters:
dataDir- - the directory path which contains sample documents (20 Newsgroups).
-
exportTerms
public String exportTerms(String destDir, String field, String delimiter)
Description copied from interface:IndexToolsExport terms from given field into a new file on the destination directory- Specified by:
exportTermsin interfaceIndexTools- Parameters:
destDir- - destination directoryfield- - field namedelimiter- - delimiter to separate terms and their frequency- Returns:
- The file containing the export
-
-