Skip to end of metadata
Go to start of metadata
Contents Summary
 

The code in below examples uses some methods defined in Common Utilities

This feature is supported by version 17.1 or greater

Merging Indexes

GroupDocs.Search for .NET API allows merging two or more indexes to one. If an index is updated frequently, it has several delta indexes and to improve search performance it is required to have a single index containing the information about all the delta indexes. The API thus has introduced "Merging Indexes" feature that can be used to merge all delta indexes in one for search performance improvement.
After performing Merge, the main index will contain all the information from the merged indexes, but the indexes that are merged remain unchanged.
Index merging has the following functionalities:

  • Merging index with delta indexes to improve search performance
  • Merging several indexes
  • Merging current index with index repository
  • Merging index with delta indexes asynchronously to improve search performance
  • Merging several indexes asynchronously
  • Merging current index with index repository asynchronously

Merging Index With Delta Indexes to Improve Search Performance

The Recipe

The index can be merged with delta indexes using the following steps:

  • Create/Load index
  • Add documents to index
  • Adding some more document folders to index, this was every time a folder is added, delta index will be created.
  • Merge all delta indexes to the index using "index.Merge()"

The Code

Merging Several Indexes

The Recipe

To merge two indexes, follow the following steps:

  • Create/load the first index and name it index1
  • Add documents to the first index
  • Create/load the second index and name it index2
  • Add documents to the second index
  • Merge data from index2 to index1 using "index1.Merge(index2)". The index2 remains unchanged.

The Code

Merging Current Index With Index Repository

The Recipe

  • Initialize an instance of IndexRepository and name it indexRepository
  • Add the first index to index repository and name it as index1, add documents to this index
  • Add the second index to index repository and name it as index2, add documents to this index
  • Create another index, directly using Index and name it as mainIndex, add documents to this index as well
  • Merge data from indexes in the repository to main index using "mainIndex.Merge(indexRepository)". After merge index repository stays unmodified

The Code

Merging Index With Delta Indexes Asynchronously to Improve Search Performance

The Recipe

An Index can be merged with delta indexes using the following steps:

  • Create/Load index
  • Add documents to index
  • Adding some more document folders to index, this was every time a folder is added, delta index will be created.
  • Merge all delta indexes to the index asynchronously using "index.MergeAsync()"

The Code

Merging Several Indexes Asynchronously

The Recipe

To merge two indexes, follow the following steps:

  • Create/load the first index and name it index1
  • Add documents to the first index
  • Create/load the second index and name it index2
  • Add documents to the second index
  • Merge data from index2 to index1 asynchronously using "index1.MergeAsync(index2)". The index2 remains unchanged.

The Code

Merging Current Index With Index Repository Asynchronously

The Recipe

  • Initialize an instance of IndexRepository and name it indexRepository
  • Add the first index to index repository and name it as index1, add documents to this index
  • Add the second index to index repository and name it as index2, add documents to this index
  • Create another index, directly using Index and name it as mainIndex, add documents to this index as well
  • Merge data from indexes in the repository to main index asynchronously using "mainIndex.MergeAsync(indexRepository)". After merge index repository stays unmodified

The Code

Labels
  • No labels