Site Search Returns Results From Other Sites: Root Cause and Fix
🔍 WiseChecker

Site Search Returns Results From Other Sites: Root Cause and Fix

When you search within a SharePoint site, you expect results only from that site. But sometimes the search results include content from other sites across your tenant. This happens because SharePoint search does not automatically scope itself to the current site. The default search box on a SharePoint site searches across the entire tenant unless you configure it otherwise. This article explains why cross-site results appear and how to fix the search scope for your site.

Key Takeaways: Scoping Search Results to a Single SharePoint Site

  • Search scope default: A SharePoint site’s search box queries the entire tenant unless you set a result source or a search vertical.
  • Result source in Search Settings: You can limit results to a single site by creating a custom result source that filters by the site’s URL or path.
  • Search vertical on the search results page: After creating a result source, you must add it as a search vertical on the modern search results page to give users a dedicated tab for site-scoped results.

ADVERTISEMENT

Why SharePoint Search Returns Results from Other Sites

SharePoint uses a single search index for the whole tenant. When a user types a query in the search box on a site, SharePoint sends that query to the search service, which returns all matching items from the index. The search box does not filter by site URL by default. This behavior is by design. It lets users find information across the organization, but it also causes confusion when someone expects site-specific results.

The root cause is the absence of a scoped result source. A result source is a search configuration object that restricts results to a specific content source, path, or file type. Without a custom result source, the search results page shows hits from every site in the tenant. The fix involves creating a result source that filters by the site’s managed path or URL, then adding that source as a search vertical on the modern search results page.

Steps to Create a Site-Scoped Result Source and Search Vertical

You need SharePoint administrator permissions or site collection owner permissions to complete these steps. The procedure uses the classic Search Settings page and the modern search results page customization.

  1. Navigate to the site’s Search Settings
    Go to the site where you want to scope search. Click the gear icon and select Site settings. Under the Search section, click Search Settings. This opens the classic search configuration page for the site.
  2. Create a new result source
    On the Search Settings page, under Result Sources, click Manage Result Sources. Click New Result Source. In the General Information section, give the source a name like “This Site Only” and set the Protocol to Local SharePoint Results.
  3. Configure the query transform
    In the Query Transform section, select the radio button for “Use the same configuration” and click Launch Query Builder. In the Query Builder, replace the existing text with this query: {searchTerms} path:"https://yourtenant.sharepoint.com/sites/yoursite". Replace the URL with the exact URL of your site. Click Test Query to verify it returns only items from that site path. Click OK to save the query.
  4. Save the result source
    Back in the New Result Source dialog, click Save. The result source now appears in the list. Click OK to return to the Search Settings page.
  5. Add the result source as a search vertical
    Go to the site’s home page. Edit the page. Click the search results web part (it may be labeled “Search Box” or “Search Results”). In the web part properties, expand the Settings section. Under the Search Vertical section, click Add vertical. Name the vertical “This Site” and select the result source you created from the dropdown. Click Apply. Publish the page.

ADVERTISEMENT

If Search Still Shows Results From Other Sites

“I created the result source but search still shows tenant-wide results”

The result source alone does not change the default search behavior. You must also add a search vertical to the modern search results page. Without the vertical, the search box still uses the default “All Sites” result source. Users must click the new “This Site” vertical on the search results page to see scoped results.

“The search vertical tab does not appear on the search results page”

The search vertical appears only when the search results web part is on the page. If you used a search box web part, the vertical tabs show on the search results page after a query. If the vertical still does not appear, check that you published the page after adding the vertical. Also verify that the result source is not set to inactive in the Search Settings.

“The query transform returns no results”

The path filter in the query transform is case-sensitive and must match the site’s exact URL. A typo or mismatch in the URL causes an empty result set. Use the full URL as it appears in the browser address bar. If the site uses a different managed path like “/teams/” instead of “/sites/”, update the path accordingly.

Result Source vs Search Vertical: Key Differences

Item Result Source Search Vertical
Description A configuration object that defines a query transform and result source type A tab on the search results page that uses a specific result source
Location Defined in Search Settings > Result Sources Defined on the search results web part properties
Function Filters search results by criteria like site path, content type, or file extension Provides a user-facing tab that applies the result source to queries
Required for site-scoped search Yes, it contains the path filter Yes, it exposes the filter to users
Default behavior without it No filtering, results from all sites Only the default “All Sites” tab appears

You now know why SharePoint site search returns results from other sites and how to fix it. Create a result source with a path filter and add a search vertical to the modern search results page. After completing these steps, users can switch to the site-scoped tab to see only content from that site. For advanced filtering, you can extend the query transform to exclude specific content types or libraries.

ADVERTISEMENT