0

Is there a way to index a subtree of items for one specific index in code? I know there's the reindex tree button but that reindexes the subtree for all indexes the items are in. I don't see a good way to filter out indexes that I don't need to update right away in the code for that button.

5

I think this code snippet should do that:

ISearchIndex index = ContentSearchManager.GetIndex("sitecore_web_index");
Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase("web");
Sitecore.Data.Items.Item startingPoint= database.GetItem("/sitecore/content/home/someStartingItem");           
index.Refresh(new SitecoreIndexableItem(startingPoint));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.