In today's tutorial, you will learn how to rebuild your Examine indexes in Umbraco V7. The default search provider that comes with Umbraco is called Examine. Under the hood, Examine uses a very popular search engine called Lucene. Out-of-the-box, when your install Umbraco it comes shipped with a public-facing index. For every published page, a corresponding entry within this index is also created. Sometimes things go wrong and the data in the index does not get updated correctly. When this happens you will need to rebuild the index, read on to learn how!

If you've never had a peek in your Umbraco's website's config folder I recommend that you have a quick peek now. In there, you'll see two files, ExamineIndex.config and ExamineSettings.config. ExamineIndex.config defines what gets indexed. ExamineSettings.config has the Lucene to Umbraco integrate bits and bobs. The easiest way to rebuild the index is to go into the backend, go to the settings tab, go to indexes and clear them. This is the recommended way, however, it is not the only way!

How To Manually Rebuild The Examine Index

If you look in ExamineIndex.config you should see a number of indexes each with an IndexPath defined. The path defines the folder path where the index files are stored on the server. The manual way to rebuild your indexes is to go onto the server and delete everything contained with that folder from the drive. Note, you may need to perform an IISRESET after you delete the index otherwise the website may act in an unexpected way. Granted deleting files manually isn't a very elegant approach, however, it works.

How To Rebuild The Examine Index In Code

If you can't easily access your server, for example, if you're using Azure, then you might want to rebuild your index on application start, or, via a custom page within the Umbraco backend. The code to rebuild a specific index is shown below:

To rebuild all the indexes, you can use this snippet:

If you are unsure on how to get Umbraco to run this code to run on application start, I recommend reading The Umbraco ApplicationEventHandler Explained. If you want to create a backend admin screen to clear the indexes, you can follow this tutorial.

That covers the three ways to clear the indexes, via the backend, manually and in code. Happy Coding 🤘