Sitecore SwitchOnRebuildLuceneIndex is the idea to offer a READ ONLY lucene index available meanwhile you are rebuilding your index. It maintains 2 directories, namely Primary and Secondary.
During our first SUGCON in Mauritius, we talked about the SwitchOnRebuildLuceneIndex. The reason is because we had lots of issues concerning this strategy. For example, our indexes were not being consistent on all our Production Servers.
Our first point of discussion is the rebuilding indexes twice. We had decompiled the Sitecore Kernel assembly and based on what we have seen, there is no need to rebuild the indexes twice. Sitecore Support also confirmed us that by design the indexes were not meant to be rebuild twice when using the SwitchOnRebuildLuceneIndex.
Second point is the Switch Directories. The SwitchOnRebuildLuceneIndex switch between the primary and secondary directory after an index has been rebuild. So, there is a great chance that on all your servers, some index may hit the primary directory and the other servers hitting the secondary directory. It is here that I think the inconsistency is being occurred. One main point to note is that switching directories only occurs when you are performing a manual rebuild index. When publishing occurs, the directories are not switched.
Third point is how to know which directory is being used on each server. In other words, on certain servers, the index being used is from the primary directory and on the others, it is the secondary directory. Below is the code which provide us the answer:
var read_update = ContentSearchManager.GetIndex("sitecore_master_index_Site One").PropertyStore.Get("read_update_dir"); var full_rebuild = ContentSearchManager.GetIndex("sitecore_master_index_Site One").PropertyStore.Get("full_rebuild_dir");
The read_update has the directory which shows which index is being read and the full_rebuild is the index that will be rebuild.
These records can also be found in the Properties Table in the Core Database. From the SQL Server, you can query the Properties Table to retrieve the information.