Troubleshooting “Search Query Failed” Error in SharePoint
When users attempt to search in SharePoint and receive the error “Search query failed”, it typically indicates a problem with the Search Service Application, Query Processing Component, Index Corruption, Crawl Failures, or Query Execution Permissions. This guide provides a detailed step-by-step approach to diagnose and resolve the issue.
Step 1: Identify the Exact Error Message
Before troubleshooting, determine the specific error details.
- Try performing a search on the SharePoint site.
- If you see an error like:
- “Search has encountered a problem and cannot display results.”
- “The query could not be completed because the search service is not available.”
- “Your query is invalid or malformed.”
- “The search request was unable to connect to the Search Service.”
- Copy the exact error message, as this will help in pinpointing the cause.
Step 2: Check ULS Logs for Detailed Errors
The Unified Logging System (ULS) logs provide additional details on search failures.
2.1: Retrieve Search Errors from ULS Logs
- Open SharePoint Management Shell as Administrator.
- Run the following command to filter search-related logs:
Get-SPLogEvent | Where-Object { $_.Category -eq "Search Query" } | Select-Object -First 20
- Check for critical errors related to search queries, such as:
- “Query Component Not Available”
- “Query Execution Timeout”
- “Insufficient Permissions for Search Query Execution”
Step 3: Verify Search Service Application
If the Search Service Application is not running properly, queries may fail.
3.1: Check Search Service Application Status
- Open Central Administration.
- Click Manage Service Applications.
- Locate Search Service Application and ensure it is started.
If it is not started, restart the service using PowerShell:
Restart-Service -Name OSearch15 -Force
Step 4: Restart the Search Query Processing Component
The Query Processing Component is responsible for processing user queries.
- Open Central Administration.
- Go to Manage Service Applications > Search Service Application.
- Click Search Administration.
- Under Search Components, check the Query Processing Component.
- If it is not running, restart it:
Restart-Service -Name SPSearchHostController -Force
Step 5: Verify the Search Index Health
A corrupted search index can cause queries to fail.
5.1: Reset the Search Index
- Open Central Administration.
- Go to Manage Service Applications > Search Service Application.
- Click Index Reset.
- Click Reset Now (⚠ This will delete the entire search index and require a full crawl).
- After resetting, perform a full crawl.
Step 6: Perform a Full Crawl to Rebuild the Index
If queries fail due to missing or outdated content in the index, a full crawl is needed.
- Open Central Administration.
- Navigate to Search Service Application > Content Sources.
- Click SharePoint Sites.
- Click Start Full Crawl.
- Monitor the Crawl Log for errors.
Step 7: Verify Search Query Permissions
The Crawl Account and Search Service Account must have proper permissions.
7.1: Check Crawl Account Permissions
- Open Central Administration.
- Go to Security > Configure Service Accounts.
- Locate the Crawl Account (e.g.,
DOMAIN\SP_Crawl). - Ensure it has Read Access to:
- Site Collections
- Content Database
- Search Administration Database
Grant read permissions using PowerShell:
$web = Get-SPWebApplication "http://YourSiteURL"
$web.GrantAccessToProcessIdentity("DOMAIN\SP_Crawl")
7.2: Verify Query Permissions in SQL Server
- Open SQL Server Management Studio (SSMS).
- Connect to the SharePoint Search Database.
- Grant SELECT and EXECUTE permissions to the Search Service Account:
GRANT SELECT, EXECUTE ON Search_Service_Application_DB TO [DOMAIN\SP_Query]
Step 8: Ensure Search Schema and Managed Properties Are Configured Correctly
Incorrect Managed Properties can cause search queries to fail.
- Open Central Administration.
- Go to Search Service Application > Search Schema.
- Check if the following Managed Properties exist:
- Title
- Content
- Author
- Modified Date
- If missing, create new property mappings.
Step 9: Check Server Resources (CPU, Memory, Disk Space)
A high server load or low disk space can cause query execution to fail.
- Open Task Manager and check:
- CPU Usage (If over 90%, restart SharePoint Server).
- Memory Usage (Ensure at least 4GB of free RAM for Search).
- Disk Space (Ensure at least 20% free disk space on the drive hosting SharePoint).
- If resources are low, increase server capacity or restart services.
Step 10: Restart SharePoint Timer Job and IIS
Restarting key services can resolve query failures.
10.1: Restart SharePoint Timer Job
Restart-Service -Name SPTimerV4
10.2: Restart IIS
iisreset /noforce
Step 11: Verify Query Throttling Settings
Large queries may be throttled in SharePoint.
- Open Central Administration.
- Go to Manage Web Applications.
- Click General Settings > Resource Throttling.
- Increase the Query Execution Limit.
Step 12: Test Search Query Using PowerShell
Run a test query to see if search is functional.
$ssa = Get-SPEnterpriseSearchServiceApplication
$query = New-Object Microsoft.Office.Server.Search.Query.KeywordQuery($ssa)
$query.QueryText = "test"
$searchExecutor = New-Object Microsoft.Office.Server.Search.Query.SearchExecutor
$results = $searchExecutor.ExecuteQuery($query)
$results.Table
- If this returns no results, the issue is with indexing.
- If an error appears, check search logs.
Step 13: Recreate the Search Service Application (If Needed)
If search is completely broken, recreate the Search Service Application.
13.1: Delete the Existing Search Service Application
- Open Central Administration.
- Navigate to Manage Service Applications.
- Select Search Service Application and Delete it.
13.2: Create a New Search Service Application
- Open Central Administration > Manage Service Applications.
- Click New > Search Service Application.
- Provide:
- Service Name (e.g.,
Search_Service_New). - Service Account (Select an existing or create a new one).
- Service Name (e.g.,
- Click OK, then perform a Full Crawl.
Step 14: Restart SharePoint Server
If the issue persists, restart the entire SharePoint server.
Restart-Computer -Force
