“Error in search query execution” – A specific error in executing the search query.

Loading

Troubleshooting “Error in Search Query Execution” in SharePoint

When you encounter an “Error in search query execution” in SharePoint, it means that the search query is failing to execute due to one or more underlying issues. These could include:

  • Incorrect search syntax
  • Corrupt or missing search index
  • Search Service Application misconfiguration
  • Query Processing Component issues
  • Database connectivity issues
  • Permissions problems
  • Time-out errors due to heavy query load

This guide will walk you through a detailed step-by-step troubleshooting process to resolve this issue.


Step 1: Identify the Exact Error Message

1.1: Check the Error Message in the UI

  1. Try running a search query in the SharePoint Search Box.
  2. Note the exact error message displayed.
  3. If possible, take a screenshot for reference.

1.2: Check the Search Query Logs

To get detailed information, check the SharePoint ULS (Unified Logging System) logs.

  1. Open SharePoint Management Shell as Administrator.
  2. Run the following PowerShell command to filter errors related to search queries: Get-SPLogLevel | ? { $_.Area -like "*Search*" } | Format-Table Area, Name, TraceSeverity
  3. Navigate to the ULS logs folder: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\LOGS
  4. Look for recent logs and search for “Query Execution” errors.

Step 2: Check Search Service and Components

If the Search Service Application or its components are not running, queries will fail.

2.1: Verify That Search Services Are Running

  1. Open Central Administration.
  2. Go to System Settings > Manage Services on Server.
  3. Ensure the following services are running:
    • Search Service
    • Search Host Controller Service
    • SharePoint Timer Service
  4. If any of these services are stopped, start them using PowerShell: Start-Service -Name OSearch15 Start-Service -Name SPSearchHostController Start-Service -Name SPTimerV4

2.2: Verify Search Components in Search Topology

  1. Open Central Administration.
  2. Navigate to Manage Service Applications > Search Service Application.
  3. Click Search Administration > Manage Search Topology.
  4. Ensure the following components are present and marked as Active:
    • Admin Component
    • Crawl Component
    • Query Processing Component
    • Index Component
    • Analytics Processing Component

If any component is missing or inactive, you may need to reconfigure the Search Topology (explained in Step 6).


Step 3: Verify Search Query Syntax

If queries are written incorrectly, they can fail.

3.1: Test a Simple Query

Try running a simple query, such as:

test OR document OR site

If this works but your original query fails, the issue may be syntax-related.

3.2: Check Query Using SharePoint Query Tool

  1. Download the SharePoint Search Query Tool from GitHub.
  2. Connect it to your SharePoint Search Service Application.
  3. Run a test query and examine the response.

3.3: Test Query Using REST API

  1. Open a browser and enter the following URL: https://[Your_Site_URL]/_api/search/query?querytext='YourSearchKeyword'
  2. If this API request returns an error, check the details of the response.

Step 4: Check Search Index and Crawl Status

If search results are outdated or missing, your search index may be corrupted.

4.1: Check Crawl Logs

  1. Open Central Administration.
  2. Navigate to Search Administration > Crawl Logs.
  3. Look for recent errors indicating crawling failures.

4.2: Reset the Search Index

If the index is corrupt, reset it.

  1. Open Central Administration.
  2. Navigate to Manage Service Applications > Search Service Application.
  3. Click Index Reset.
  4. Click Reset Now (⚠ This will remove all indexed data).
  5. Start a Full Crawl to rebuild the index:
    • Go to Content Sources.
    • Click Start Full Crawl.

Step 5: Check Search Query Permissions

If the query execution account does not have proper permissions, it may fail.

5.1: Verify Query Execution Account in Search Service Application

  1. Open Central Administration.
  2. Navigate to Security > Configure Service Accounts.
  3. Check the account running the Search Service Application.
  4. Ensure it has the required permissions:
    • db_owner on Search Databases
    • Full Read on Web Applications

Step 6: Reconfigure Search Topology (If Needed)

If search components are misconfigured or missing, reconfigure them.

6.1: Reset Search Topology Using PowerShell

  1. Open SharePoint Management Shell as Administrator.
  2. Run the following PowerShell commands: $ssa = Get-SPEnterpriseSearchServiceApplication New-SPEnterpriseSearchTopology -SearchApplication $ssa $server = Get-SPEnterpriseSearchServiceInstance New-SPEnterpriseSearchAdminComponent -SearchTopology $ssa -SearchServiceInstance $server New-SPEnterpriseSearchCrawlComponent -SearchTopology $ssa -SearchServiceInstance $server New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $ssa -SearchServiceInstance $server New-SPEnterpriseSearchIndexComponent -SearchTopology $ssa -SearchServiceInstance $server New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $ssa -SearchServiceInstance $server New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $ssa -SearchServiceInstance $server Set-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
  3. Restart the search services: Restart-Service -Name OSearch15 Restart-Service -Name SPSearchHostController

Step 7: Restart IIS and SharePoint Timer Service

7.1: Restart IIS

iisreset /noforce

7.2: Restart SharePoint Timer Service

Restart-Service -Name SPTimerV4

Step 8: Test the Search Query Again

  1. Go to a SharePoint site and perform a search.
  2. Use different keywords to test multiple queries.
  3. If results now appear, the issue is resolved.

Leave a Reply

Your email address will not be published. Required fields are marked *