Updates an index of an old version to the latest version.
Depending on the old version, the index data are converted or its documents are re‑indexed; in the latter case the source documents must be available at their original paths. The updated index is written to new_index_path, while the original index at index_path remains unchanged.
The directory for the updated index. If the index can be updated, the directory is created if it does not exist; otherwise its content is deleted before the updated index is written. When the update fails, the content may already be deleted.
Returns: VersionUpdateResult: The result of the index version update operation.
Raises
Description
ValueError
If new_index_path is empty, or it is the same as index_path, a parent directory of it, or a directory that contains part of the index data.
IOError
If a file or directory of the index or new_index_path cannot be accessed, or if the index in index_path is damaged and cannot be converted.
PermissionError
If access to a file or directory of the index or new_index_path is denied.
Example
fromgroupdocs.searchimportIndex,IndexUpdaterfromgroupdocs.search.commonimportVersionUpdateResultsource="./old_index"target="./new_index"updater=IndexUpdater()ifupdater.can_update_version(source):result=updater.update_version(source,target)ifresult==VersionUpdateResult.UPDATED:index=Index(target)print(f"Updated index contains {len(index.get_indexed_documents())} documents")
Aliases
These names call update_version too, limited to the overloads listed.