How to temporarily disable sitecore indexing while editing items

I am developing a Sitecore project that has several data import jobs that work on a daily basis. Each time a task runs, it can update a large number of Sitecore elements (thousands), and I noticed that all these changes trigger updates to the Solr index.

My concern is that I'm not sure if it is better or to update everything at the end of the assignment. Therefore, I would like to try both options. Can someone tell me how can I use the code to temporarily disable Lucene / Solr indexing and enable it later when I finish editing all the elements?

+4
source share
3 answers

, , . , , , .

, Sitecore 7 , , :

IndexCustodian.PauseIndexing();
IndexCustodian.ResumeIndexing();

:

http://blog.krusen.dk/disable-indexing-temporarily-in-sitecore-7/

+3

/, BulkUpdateContext. , EventDisabler, , . EditContext . , - :

using (new BulkUpdateContext())
using (new EditContext(targetItem, false, true))
{
    // insert update logic here...
}

, : Sitecore CMS

+3

@Martin (silent = true), , - :

item.Editing.BeginEdit();
//Change fields values
item.Editing.EndEdit(true,true);

EndEdit() , , /.

, , , .

, : , RootItemInTree :

var index = Sitecore.ContentSearch.ContentSearchManager.GetIndex("Your_Index_Name")
index.Refresh(new SitecoreIndexableItem(RootItemInTree));
+2

Source: https://habr.com/ru/post/1599222/


All Articles