org.cdlib.xtf.textIndexer
Class IdxTreeOptimizer
Object
IdxTreeOptimizer
public class IdxTreeOptimizer
- extends Object
This class provides a simple mechanism for optimizing Lucene indices
after new documents have been added , updated, or removed.
When documents are added to a Lucene index, they form a "segment" that
contains information about the location and frequency for words appearing
in the document. Optimizing a Lucene index consists of merging multiple
segments into a single large segment. Doing so speeds searching by
eliminating the need to search multiple segments and combine the results.
To use this class, simply instantiate a copy, and call the
processDir()
method on a directory containing an index. Note that the directory passed
may also be a root directory with many index sub-directories if desired.
Method Summary |
void |
optimizeIndex(File idxDirToOptimize)
Performs the actual work of optimizing a Lucene index. |
void |
processDir(File dir)
Create an IdxTreeOptimizer instance and call this method to
optimize one or more Lucene indices. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IdxTreeOptimizer
public IdxTreeOptimizer()
processDir
public void processDir(File dir)
throws Exception
- Create an
IdxTreeOptimizer
instance and call this method to
optimize one or more Lucene indices.
- Parameters:
dir
- The index database directory optimize. May be a
directory containing a single index, or the root
directory of a tree containing multiple indices.
- Throws:
Exception
- Passes back any exceptions generated by the
optimizeIndex()
function, which is called for each index sub-directory
found.
- Notes:
- This method also calls itself recursively to process
potential index sub-directories below the passed
directory.
optimizeIndex
public void optimizeIndex(File idxDirToOptimize)
throws Exception
- Performs the actual work of optimizing a Lucene index.
- Parameters:
idxDirToOptimize
- The index database directory clean. This
directory must contain a single Lucene index.
- Throws:
Exception
- Passes back any exceptions generated by Lucene
during the opening or optimization of the
specified index.