Search has encountered a problem that prevents results from being returned
When writing search queries in C# code you sometimes get the following error.
“Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator.”
In most cases it indicates that your search schema is not correctly setup. You request certain functionality in your code but your ‘Search Properties’ are not correctly configured.
For example the following code returned the above error:
query.SortList.Add("PublishingdateOWSDATE", SortDirection.Descending); query.ResultTypes = ResultType.RelevantResults; ResultTableCollection queryResults = query.Execute();
The reason of the error was simple.
The search property “PublishingdateOWSDATE” was not configured for sorting.
To fix this: go to central Admin -> Manage service Applications -> Search Service Application -> Search Schema.
Find the property “PublishingdateOWSDATE”, click on it and enable sorting by selecting “Latent” or “Active” from the dropdownlist:
Do a new crawl of your content (incremental worked for me) and test you code again.
So when getting a “Search has encountered a problem …” , always check if your search properties configuration (sorting, include in search, property name, …) is in line with the used functionality in your code.