Limiting Search Results in SharePoint 2013

The other day a client tells me that he wants to limit the results of their SharePoint, but it was a bit different that I was used to.

In this case, they have a webapp where are different site collections, but few weeks ago I created a new site collection to integrate SharePoint with Navision. My client wanted the search results from Navision separated from the general Search results.

So in this case I have the appweb (http://myappweb) and a site collection for Navision (http://myappweb/navision)

So I decided to do the following:

To exclude the Navision results from the main searchcenter, I edit the SearchResults webpart, and in the querybox I type the following:

{searchboxquery} -path:http://myappweb/navision

By doing this, I’m excluding the Navision search results from the main search center.

But wait, you’ll thinking, and what happen with the search results from the Navision site collection?

In this case we want to limítate the search results to only this site collection, so we have to create a result source to achieve this.

Navigate to your SSA on Central Admin and click Result Sources in the left hand menu.


Next click “New Result Source”. This would be equal to a new search scope. Give the result source a name, leave the radio button on “Local SharePoint” as we’re searching local content. The limiting rule is then added in the Query Transform box. You can either launch the Query Builder or manually append your limiting query to the user query.

In this sample you will end up with the query:

{searchTerms} path:http://myappweb/navision

{searchTerms} is a placeholder for the user query, and the last bit will make sure only items starting with are included.


Finally you will save the newly created Result Source.

Now that you have create the Result Source (or scope) you need to configure your search page to use it. Navigate to your search result page and enter edit mode. Next edit the Search Results Web Part and click the Change query button.

In the query builder dialog you can now choose your new result source in the top dropdown.

Click OK, save your page, wait a few seconds for the change to be picked up and results should be limited to http://myappweb/navision.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s