3

To remove a particular item from Search Index, we can go to SSA (Search Service Administration) in CA (Central Administration) and click on Crawl log and URL view, then Remove the item from Index is possible.

Is there anyway, where we can use PowerShell/Code to perform the same task?

Could not find the answer here in as well Similar Question

References: Technet Link


Edit: Resetting the index is a no-go, also I don't want to exclude them via query rules in the results web part.

I assume that if I can delete them one by one in CA that there is a method to feed a couple of thousands at once to it to delete.

Checked here , https://www.reddit.com/r/sharepoint/comments/3skyzg/delete_items_from_index/ --> But that code is not working for me, any ideas?

1

1 Answer 1

0

Article you mentioned is OK but instead of using URLID, I've been using FullUrl which work well for me.

Here is definition of method for removing RemoveDocumentFromSearchResults: https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-server/jj517804(v=office.15)

and for getting URLs GetCrawledUrls: https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-server/jj264492(v=office.15)

I'll post full code if someone will need this too:

$ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Enterprise Search Service"

$cl = New-Object Microsoft.Office.Server.Search.Administration.CrawlLog $ssa

$logEntries = $cl.GetCrawledUrls($false,1500000,"https://{Path to list or site}",$true,-1,-1,-1,[System.DateTime]::MinValue, [System.DateTime]::MaxValue)
    
$logEntries | ForEach-Object { $cl.RemoveDocumentFromSearchResults($_.FullUrl); write-host "REMOVED: " $_.FullUrl; }

Hope this helps someone,

Andrew

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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