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 void
addDocument(Document doc, Analyzer analyzer)
Add new document to this index.CheckIndex.Status
checkIndex(PrintStream ps)
Check the current index status.void
createNewIndex()
Create a new index.void
createNewIndex(String dataDir)
Create a new index with sample documents.void
deleteDocuments(Query query)
Delete documents from this index by the specified query.void
optimize(boolean expunge, int maxNumSegments, PrintStream ps)
Execute force merges.void
repairIndex(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:IndexTools
Execute force merges.Merges are executed until there are maxNumSegments segments.
When expunge is true, maxNumSegments parameter is ignored.- Specified by:
optimize
in 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:IndexTools
Check the current index status.- Specified by:
checkIndex
in interfaceIndexTools
- Parameters:
ps
- information stream- Returns:
- index status
-
repairIndex
public void repairIndex(CheckIndex.Status st, PrintStream ps)
Description copied from interface:IndexTools
Try 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:
repairIndex
in interfaceIndexTools
- Parameters:
st
- - index statusps
- - information stream
-
addDocument
public void addDocument(Document doc, Analyzer analyzer)
Description copied from interface:IndexTools
Add new document to this index.- Specified by:
addDocument
in interfaceIndexTools
- Parameters:
doc
- - document to be addedanalyzer
- - analyzer for parsing to document
-
deleteDocuments
public void deleteDocuments(Query query)
Description copied from interface:IndexTools
Delete documents from this index by the specified query.- Specified by:
deleteDocuments
in interfaceIndexTools
- Parameters:
query
- - query for deleting
-
createNewIndex
public void createNewIndex()
Description copied from interface:IndexTools
Create a new index.- Specified by:
createNewIndex
in interfaceIndexTools
-
createNewIndex
public void createNewIndex(String dataDir)
Description copied from interface:IndexTools
Create a new index with sample documents.- Specified by:
createNewIndex
in interfaceIndexTools
- Parameters:
dataDir
- - the directory path which contains sample documents (20 Newsgroups).
-
-