Method AddIndexesNoOptimize
AddIndexesNoOptimize(Directory[])
Merges all segments from an array of indexes into this index.
This may be used to parallelize batch indexing. A large document collection can be broken into sub-collections. Each sub-collection can be indexed in parallel, on a different thread, process or machine. The complete index can then be created by merging sub-collection indexes with this method.
NOTE: the index in each Directory must not be changed (opened by a writer) while this method is running. This method does not acquire a write lock in each input Directory, so it is up to the caller to enforce this.
NOTE: while this is running, any attempts to add or delete documents (with another thread) will be paused until this method completes.
This method is transactional in how Exceptions are handled: it does not commit a new segments_N file until all indexes are added. This means if an Exception occurs (for example disk full), then either no indexes will have been added or they all will have been.
Note that this requires temporary free space in the Directory up to 2X the sum of all input indexes (including the starting index). If readers/searchers are open against the starting index, then temporary free space required will be higher by the size of the starting index (see Optimize() for details).
Once this completes, the final size of the index will be less than the sum of all input index sizes (including the starting index). It could be quite a bit smaller (if there were many pending deletes) or just slightly smaller.
This requires this index not be among those to be added.
NOTE: if this method hits an OutOfMemoryError you should immediately close the writer. See above for details.
Declaration
public virtual void AddIndexesNoOptimize(params Directory[] dirs)
Parameters
Type | Name | Description |
---|---|---|
Directory[] | dirs |