Ali
Ali

Reputation: 1225

Sitecore Index Rebuild, Deletes exiting index files

I am working with Sitecore 7 search, I am rebuilding index in code, I have created an Agent for that, things are working, index rebuild takes 15 seconds, I noticed while index is rebuilding I can't search any content, search gives me 0 results, I think index files are removed from index folder when index is rebuilt, is that right? How can I rebuild index without deleting existing index files?

Upvotes: 1

Views: 1684

Answers (1)

Stephen Pope
Stephen Pope

Reputation: 3551

You are correct, when a rebuild is issued then the existing index is dropped. To avoid this, you need to change the index type from the default LuceneIndex to a SwitchOnRebuildLuceneIndex

<index id="sitecore_master_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">

..to..

<index id="sitecore_master_index" type="Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex, Sitecore.ContentSearch.LuceneProvider">

This will create a secondary index folder in which the rebuild will take place. When the re-index is complete it will swap the two index folders so that you do not see any downtime of your searches.

There is an equivalent version for the Solr provider as well.

You can see blog posts: HERE or HERE for a little more information.

Upvotes: 5

Related Questions