In SharePoint , you may want to trigger a complete
re-indexing of your site. This manipulation is possible with the site
administration.
You can do the same thing with PowerShell by changing
the value of the web property vti_searchversion
Below is a PowerShell function that re-index the entire site collection, it will update the vti_searchversion value, which will trigger a complete site collection re- indexing that will be considered in the next crawling.
function ReindexSite{
param($web)
Write-Host -ForegroundColor
Yellow " Reindexing Site : " $ web.Title
[int] $version = 0
$propertyBag = $ web.AllProperties
if
($propertyBag.ContainsKey("vti_searchversion") -eq $true)
{
$version = $propertyBag["vti_searchversion"]
}
Write-Host "Current
search version: " $version -ForegroundColor Yellow
$version++
$propertyBag ["vti_searchversion"] = $version
Write-Host "Updated
search version: " $version -ForegroundColor Green
$web.Update()
foreach ($subWeb in $ web.Webs)
{
ReindexSite($subWeb)
}
}
You can do
also the same thing in SharePoint Online with this script:
function ReindexSite{
param($web)
$subWebs =
$web.Webs
$clientContext.Load($web)
$propertyBag
= $ web.AllProperties
$allProperties
= $web.AllProperties
$clientContext.Load($
propertyBag
)
$clientContext.Load($subWebs)
$clientContext.ExecuteQuery()
Write-Host -ForegroundColor
Yellow " Reindexing Site : " $ web.Title
[int] $version = 0
$propertyBag = $ rootWeb.AllProperties
if ($
propertyBag
.FieldValues.ContainsKey("vti_searchversion")
-eq $true)
{
$version = $
propertyBag
["vti_searchversion"]
}
Write-Host "Current
search version: " $version -ForegroundColor Yellow
$version++
$
propertyBag
["vti_searchversion"] =
$version
Write-Host "Updated
search version: " $version -ForegroundColor Green
$web.Update()
$clientContext.ExecuteQuery()
foreach ($subWeb in $subWebs)
{
ReindexSite($subWeb)
}
}
2 commentaires
Hello, is there such a thing for a list?
ReplyHello, yes you can do the same thing for a list. You should go to "List Settings > Advanced settings and you should click the button "Reindex List". The all content of your List or Library will be reindexed during the next scheduled crawl. Hope this help you.
ReplyEnregistrer un commentaire