How to rebuild sitecore search indexes?
You might come upon certain situations where you need to rebuild Sitecore search indexes instantly for ex: when you deploy huge contents into the live production environment if the indexes are out of date, or when the indexes get corrupted.
Below are the three different ways to rebuild Sitecore search indexes.
Rebuild index using Sitecore control panel
- Login to Sitecore and open the control panel
- Scroll down to the indexing section and click on the link Indexing Manager. An overlay will open with all the local indexes names.
- Select the indexes which you need to rebuild, let us say if you would like to re-index the master database then select sitecore_master_index and click on the rebuild button.
- This might take some time depending on the number of items on the Sitecore, once the indexing is finished you would be able to search the item.
Rebuild Sitecore Search Index Programmatically
Sitecore has an API which allows you to rebuild the indexes. You could use this approach to rebuilding the search index whenever items are published to the production environment.
You can rebuild indexes from custom code by running a script similar to one of these from a custom .aspx page:
// To rebuild "new" search indexes, use this piece of code for every "new" index
IndexCustodian.FullRebuild(ContentSearchManager.GetIndex("[INDEX NAME]", true);
// Or to rebuild all indexes, use the following piece of code:
Rebuild Sitecore Search Indexes Using the Content Editor
To Rebuild Sitecore Indexes from the Content Editor follow the below steps:-
- Login to the Sitecore and navigate to the Content Editor, click the Developer tab.
Note: If you do not see the Developer tab, right-click in the menu bar and select Developer in the list of tabs.
- In the Indexing tools group, select one of the options to rebuild indexes:
- Rebuild index – opens a list of all indexes. This list contains information about when each index was last rebuilt. Select an index to rebuild it.
- Rebuild all – rebuilds all indexes.
- Re-Index Tree – process the selected item and all descendants recursively, and force an update operation on all indexes that are related to the selected content area.
Note: Use this command only in situations where incremental indexing is either not working as expected, or when you use the manual update strategy. You should only do this when absolutely necessary.