If you’ve ever worked with large amounts of data within Sitecore, chances are you’ve worked with Lucene Indexes (or the newly branded Sitecore.Search namespace and indexes). If you haven’t worked with these, it’s worth the time (and initial frustration) to learn about them, as they really do improve performance when querying the Sitecore content tree. There are of course some gotchas relating to Indexes though. One I’ve already covered is using a MustNot QueryOccurance. Another is what happens when a content manager moves an item into or out of a folder that is the root for one of your indexes? This post will cover some of our experiences in how you can get your indexes to properly display accurate data in this situation.
When we built Perficient.com using Sitecore, we set up a number of Sitecore Search indexes for different pieces of our data, like Events and Awards. One of the issues we ran into was that our indexes weren’t updating properly if a content manager dragged a content item from a folder that was indexed, and moved it into another folder (either indexed, or non-indexed). We did some experimenting, and came up with the following fairly simple and straight-forward rule set regarding moving content that is in indexed folders.
Moving Content into or out of an index
- If you remove items from an indexed folder by dragging them to another folder or by deleting them, you must Smart Publish the indexed folder. If you publish incrementally, the index will not be rebuilt. Worse, Smart Publish or Republishing after an incremental publish will NOT correct the problem. At that point, the only thing that works is to Rebuild the index with the Index Viewer.
- The same is not true of dragging items into an indexed folder. Any kind of publish will update the index
After we discovered those sets of rules, we came to the simple conclusion that when training content managers, we need to point out to them what the indexed folders are and tell them that whenever they update an item within one of those folders, they should perform a Smart Publish.