How to reindex content
- 6.4 Patch 1
Sense/Net ECM is built on a powerful indexing technology that lets us provide the super-simple Content Query feature for finding Content stored in the Content Repository. There are cases however when the indexed information of certain content needs to be refreshed or completely rebuilt. This article is for developers how want to create tools or custom SnAdmin steps for re-indexing content.
This article is about the C# and OData API Sense/Net ECM provides for rebuilding index documents for individual content items or subtrees. This is the recommended way for developers instead of executing the Index Populator tool on the whole Content Repository as that may take a long time in case of a huge database.
Index populator tool
We provide a tool for refreshing the whole Lucene index in the file system called the Index Populator. In most cases you will not need to execute that tool but it can be useful when you want to create a fresh, correct index using the index data that is already stored in the database.
Refresh or rebuild
The index populator tool (see above) simply loads the already existing index data for every single content from the database. It does not load content into memory and does not extract data from content fields. This is what we call refreshing the index document. Refresh simply updates the index information in the Lucene index directory in the file system.
There are cases when hard indexing needs to be performed: in this case we load the original content into memory and perform the extract operation for every field again, the same way as we do it at the end of a save operation. This is what we call rebuilding the index document and it is not possible with the tool above.
The IndexRebuildLevel enum type has the following values that reflect these two modes:
- IndexOnly (only refresh the index document in the file system)
- DatabaseAndIndex (rebuild the index data, save it to the database than to the file system)
It is possible to refresh/rebuild index information for a single content or a whole subtree (all children and subfolders) under a content. Usually you will need the latter but the C# API lets you decide.
The following method lets developers reindex a single content or a whole subtree, depending on the parameters. Default is not recursive and index only.
var myContent = Content.Load(path); myContent.RebuildIndex(true, IndexRebuildLevel.DatabaseAndIndex);
The following built-in OData actions are available for refreshing or rebuilding index documents.
- RebuildIndex: Rebuilds or just refreshes the Lucene index document of a content and optionally of all documents in the whole subtree.
- RebuildIndexSubtree: Performs a full reindex operation on the content and the whole subtree.
- RefreshIndexSubtree: Refreshes the index document of the content and the whole subtree using the already existing index data stored in the database.
- Content Repository
- Field Indexing
- Index Populator
- Built-in OData actions and functions
- How to create a custom step for SnAdmin
There are no related external articles for this article.