Method AddIndexes
AddIndexes(Directory[])
Adds 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: this method acquires the write lock in each directory, to ensure that no IndexWriter is currently open or tries to open while this is running.
This method is transactional in how
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 ForceMerge(Int32) for details).
NOTE: this method only copies the segments of the incoming indexes and does not merge them. Therefore deleted documents are not removed and the new segments are not merged with the existing ones.
This requires this index not be among those to be added.
NOTE: if this method hits an
Declaration
public virtual void AddIndexes(params Directory[] dirs)
Parameters
Type | Name | Description |
---|---|---|
Directory[] | dirs |
Exceptions
Type | Condition |
---|---|
CorruptIndexException | if the index is corrupt |
LockObtainFailedException | if we were unable to acquire the write lock in at least one directory |
AddIndexes(IndexReader[])
Merges the provided indexes into this index.
The provided IndexReaders are not closed.
See AddIndexes(IndexReader[]) for details on transactional semantics, temporary
free space required in the Directory, and non-CFS segments on an
NOTE: if this method hits an
NOTE: empty segments are dropped by this method and not added to this index.
NOTE: this method merges all given IndexReaders in one
merge. If you intend to merge a large number of readers, it may be better
to call this method multiple times, each time with a small set of readers.
In principle, if you use a merge policy with a mergeFactor
or
maxMergeAtOnce
parameter, you should pass that many readers in one
call. Also, if the given readers are DirectoryReaders, they can be
opened with termIndexInterval=-1
to save RAM, since during merge
the in-memory structure is not used. See
Open(Directory, Int32).
NOTE: if you call Dispose(Boolean) with false
, which
aborts all running merges, then any thread still running this method might
hit a MergePolicy.MergeAbortedException.
Declaration
public virtual void AddIndexes(params IndexReader[] readers)
Parameters
Type | Name | Description |
---|---|---|
IndexReader[] | readers |
Exceptions
Type | Condition |
---|---|
CorruptIndexException | if the index is corrupt |