Thursday, 6 March 2014

Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator



Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator


If you are working in SharePoint Online
Solution: Just Ctrl+F5

If still you are facing the issue, check the result source.
-------------------------------------------------------------
If you are working with Onprem SharePoint
Solution: Just Ctrl+F5

If still you are facing the issue, check the result source.
Recreate the search service application from Central Administration.

if above option not works, create search service application through powershell.

Create a new Service Application:

$ServiceApplication = New-SPEnterpriseSearchServiceApplication
    -Name "Search Service Application"
    -ApplicationPool $spAppPoolName
    -DatabaseServer  "YOURSERVERNAME"
    -DatabaseName  "Database Name"

Create a new Service Application Proxy:

New-SPEnterpriseSearchServiceApplicationProxy
    -Name "Search Service Application Proxy" -SearchApplication "Search Service Application"

Get the Search Instance. The instance is used to associate new Search Components (crawl, query, admin…) create later with the instance itself:
$searchInstance = Get-SPEnterpriseSearchServiceInstance -local

Get the active Search Topology. This is used to monitor the state of the old search topology which becomes inactive if the new one gets active:
$InitialSearchTopology = $ServiceApplication | Get-SPEnterpriseSearchTopology -Active

Create a new Search Topology. New Search Components  (crawl, query, admin…) have to be associated with a search instance and a search topology.
$SearchTopology = $ServiceApplication | New-SPEnterpriseSearchTopology
Create Administration Component and Processing Components. Here you need the search instance and new search topology from above:

New-SPEnterpriseSearchAdminComponent
    -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
         New-SPEnterpriseSearchAnalyticsProcessingComponent
    -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
         New-SPEnterpriseSearchContentProcessingComponent
    -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
         New-SPEnterpriseSearchQueryProcessingComponent
    -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance

Create a new Crawl Component:
New-SPEnterpriseSearchCrawlComponent
    -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance

Create a new Index (Query) Component:

New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology
    -SearchServiceInstance $searchInstance -RootDirectory $IndexLocation

Note:
In SharePoint 2010 the PowerShell cmdlet was New-SPEnterpriseSearchQueryComponent.
The ‘RootDirectory’ property requires and existing AND empty folder like "C:\Program Files\Microsoft Office Servers\15.0\Data\Office Server\Applications\Index". If not existing OR not empty it fails.

Activated the new Search Topology and deactivate the old one:
$SearchTopology | Set-SPEnterpriseSearchTopology

Note:
I encountered that activating the topology requires all components created first, otherwise you get an error e.g. 'Set-SPEnterpriseSearchTopology : At least one index partition does not contain any components.'
In SharePoint 2010 the cmdlet was Set-SPEnterpriseSearchQueryTopology.
The old topology wasn't set to inactive for 15 minutes although TechNet says: "This cmdlet enables the search topology with the given identity, marking the currently active search topology as inactive." So maybe I didn't allocated enough system resources (especially I was short of RAM) or it takes more time.

Remove the old Search Topology:

do { Write-Host -NoNewline .;Start-Sleep 6;}
while ($InitialSearchTopology.State -ne "Inactive")
$InitialSearchTopology | Remove-SPEnterpriseSearchTopology -Confirm:$false