1

We have to rebuild Lucene index on our CD server.
Is there any Sitecore API to rebuild Lucene index? or rebuild a portion of tree items?

  • do you have a specific requirement to have to manually trigger the reindex on a CD node? You can configure your indexing strategies to have Sitecore rebuild those for you without the need of a manual intervention. For example when publishing a item to rebuild the indexes... You can check more about this here doc.sitecore.net/sitecore_experience_platform/… – Diego Nov 30 '17 at 13:31
  • we have configured publishAsync strategy in configuration. Sometimes if we rebuild the index it solve the problem . if we feel some specific items are not coming in this we will rebuild specific item only. – Abhimanyu Singh Nov 30 '17 at 13:39
  • Are you seeing any errors on logs? If you address the cause of why some items are going through and others not you probably don't need to manually rebuild the indexes. – Diego Nov 30 '17 at 13:44
  • I am very much sure if you have configure indexing strategies properly, you don't need to think in API way to rebuild Lucene. As Diego suggest you should try to address the cause, unless there any specific requirement. – Mahendra Shekhawat Nov 30 '17 at 14:27
  • Rebuilding the index with is a another backup plan if anything happens wrong. – Abhimanyu Singh Nov 30 '17 at 15:02
10

You should have a look at the documentation form Sitecore:

https://doc.sitecore.net/sitecore_experience_platform/80/setting_up_and_maintaining/search_and_indexing/indexing/rebuild_search_indexes

You can rebuild indexes from custom code by using this:

// To rebuild "new" search indexes, use this piece of code for every "new" index    
IndexCustodian.FullRebuild(ContentSearchManager.GetIndex("[INDEX NAME]"), true);

To rebuild all indexes:

// Or to rebuild all indexes, use the following piece of code:
IndexCustodian.RebuildAll();

If you would like to index a single item:

IndexCustodian.Refresh(ContentSearchManager.GetIndex("[INDEX NAME]"), itemToRefresh);

If you need to index a tree:

SitecoreIndexableItem indexableFolder = new SitecoreIndexableItem(item);     
IndexCustodian.RefreshTree(indexableFolder);
| improve this answer | |
  • is there any option to rebuild some items or portion of tree items? – Abhimanyu Singh Nov 30 '17 at 13:22
  • I have added a code snippet for refresh tree aswell. Hopefully it will help you. – Thomas Bæk Nov 30 '17 at 13:27
  • we will try with this, hope it may solve the problem. – Abhimanyu Singh Nov 30 '17 at 13:42

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.