We came across a challenge where we want to index particular item in Sitecore without running indexing job. Whenever we run indexing job from Sitecore dashboard it will require large amount of time to complete indexing. Also it will index everything present in content tree. We do not have feasibility to index particular item. We discovered script which will help to perform this task.
Script
#Selecting Index $index = [Sitecore.ContentSearch.ContentSearchManager]::GetIndex("sitecore_master_index") #Selecting Item $indexItem = Get-Item -Path "master:\content\home\TestItem" #Indexing Item [Sitecore.ContentSearch.Maintenance.IndexCustodian]::Refresh($index, [Sitecore.ContentSearch.SitecoreIndexableItem]$indexItem)
In above script we need to specify the index name and item name that we need to add. Above command needs to be executed in Sitecore PowerShell Console. After executing this Command item will get indexed.
If you to index multiple items inside content tree you can use below script.
Script
#Selecting Items $itemsToBeIndexed=Get-ChildItem -Path "master://sitecore/content/Documents/" -Recurse; #Selecting Index $index = [Sitecore.ContentSearch.ContentSearchManager]::GetIndex("sitecore_master_index") foreach ($indexItem in $itemsToBeIndexed) { #Indexing Items [Sitecore.ContentSearch.Maintenance.IndexCustodian]::Refresh($index, [Sitecore.ContentSearch.SitecoreIndexableItem]$indexItem) }
I hope you will find this information useful.
No comments:
Post a Comment