Content Indexing and Search Folders

[This is now documented here: ]

I recently had a customer who noticed that their MAPI search folders weren’t updating properly when they moved to Exchange 2010. Their wasn’t anything complicated about the search criteria – they called SetSearchCriteria passing a RES_CONTENT type restriction looking for PR_MESSAGE_CLASS matching their item type. The search folder which was initially built was correct – it had all the items in it which it was supposed to have and nothing else. But as items were created and deleted, the search folder didn’t keep up. Additionally, they noted that the same criteria worked on Exchange 2007, and that on some Exchange 2010 servers, they didn’t see the problem at all.

To troubleshoot this issue, the first thing we did was use MFCMAPI to look at the search folder they created. If you right click on a folder with MFCMAPI, you can select Edit Search Criteria, which will cause MFCMAPI to call GetSearchCriteria and display the results. Comparing the working search folders to the non-working search folders exposed the problem – all of the non-working folders had the SEARCH_STATIC flag set on them. So as far as Exchange was concerned, all of these folders were working correctly. The static folders didn’t update, while the non-static, or dynamic folder, updated dynamically.

But why were these folders static? This was caused by Content Indexing. On the Exchange 2010 servers where the folders were working, Content Indexing wasn’t. In fact, I went to a non-working server and manually disabled Content Indexing. When I rebuilt the search folder SEARCH_STATIC wasn’t set. It turns out, on Exchange 2010, search folders backed by Content Indexing are always static. A little digging uncovered that on Exchange 2007, even though we had intended Content Indexing backed search folders to be static, we had accidently made them dynamic. So that’s why the folders were working on 2007.

Once we realize Content Indexing is the problem, the fix is simple – when building the search folder, ask that Content Indexing not be used. There’s a flag for this, NON_CONTENT_INDEXED_SEARCH (0x20000). Once we passed this flag, Exchange didn’t use Content Indexing to build the search folder, SEARCH_STATIC wasn’t set, and the search folder started updating dynamically.

Comments (2)

  1. Dmitry Streblechenko says:

    Just a clarification that NON_CONTENT_INDEXED_SEARCH is an Exchange specific flag, so you need to either make sure you use it only with the Exchange provider, or watch out for the MAPI_E_UNKNOWN_FLAGS error, clear that bit, and then retry SetSearchCriteria.

  2. David Embury says:

    Was anything done about this? It seems every mailbox moved to Exchange 2010 SP1 gets all its search fodlers destroyed in the process and the only fix is a one by one event!

Skip to main content