Merges the specified index into the current index.
If the other index has a previous version, it must be updated before merging with IndexUpdater.
The indexes must divide the text of documents into terms in the same way; a search finds a document reliably only if the document was indexed with the dictionaries and settings that the index uses. The operation compares the current index with the other index if it contains documents: the settings IndexSettings.use_stop_words, IndexSettings.use_character_replacements, IndexSettings.replace_unpaired_surrogates and IndexSettings.skip_blended_only_terms, the alphabet, the tokenization dictionary, the stop word dictionary if the indexes use stop words, and the character replacement dictionary if the indexes use character replacements. If a difference is found, the operation throws a RuntimeError and no index is changed.
The alphabet, the tokenization dictionary, the stop word dictionary and the character replacement dictionary of the current index are not changed by the operation. The other dictionaries of the other index are merged into the dictionaries of the current index.
defmerge(self,index,options):...
Parameter
Type
Description
index
Index
The index to merge into.
options
MergeOptions
The merge options.
Raises
Description
RuntimeError
The other index contains documents and divides their text into terms differently from the current index.
Example
fromgroupdocs.searchimportIndexfromgroupdocs.search.optionsimportMergeOptionsfromgroupdocs.search.commonimportCancellationindex1=Index("./index1")index1.add("./documents")index2=Index("./index2")index2.add("./documents2")options=MergeOptions()options.cancellation=Cancellation()try:index1.merge(index2,options)exceptRuntimeErrorasexc:print(exc)print("Documents in index1:",len(index1.get_indexed_documents()))
merge
Merges indexes from the specified index repository into the current index.
If other indexes have a previous version, they must be updated before merging with IndexUpdater.
The indexes have to divide the text of documents into terms in the same way: a search finds a document reliably only if the document was indexed with the dictionaries and settings that the index uses. The operation compares the current index with every index of the repository that contains documents: the settings IndexSettings.use_stop_words, IndexSettings.use_character_replacements, IndexSettings.replace_unpaired_surrogates and IndexSettings.skip_blended_only_terms, the alphabet, the tokenization dictionary, the stop word dictionary if the indexes use stop words, and the character replacement dictionary if the indexes use character replacements. If a difference is found, the operation throws a RuntimeError and no index is changed.
The alphabet, the tokenization dictionary, the stop word dictionary and the character replacement dictionary of the current index are not changed by the operation. The other dictionaries of the other indexes are merged into the dictionaries of the current index.
defmerge(self,repository,options):...
Parameter
Type
Description
repository
IndexRepository
The index repository to merge into.
options
MergeOptions
The merge options.
Raises
Description
RuntimeError
An index of the repository contains documents and divides their text into terms differently from the current index.