Limit Results to a Specific Library in SharePoint

September 12, 2014

This honk goes out to SharePoint users in the crowd. In a post titled “SharePoint Search *Quirks: Query Variables,” the MSDN SharePoint Strategy blog addresses a common question: How can one limit results to a specific library in a specific site collection? The write-up points us to the MS resource page, “Query Variables in SharePoint Server.” We think the examples really underscore the user-friendliness of
SharePoint search. Here’s the first example:

“To scope to this site collection: {searchTerms} SPSiteURL:{SiteCollection.Url}

*By using the {SiteCollection.Url} variable, you could define, say a [result source, query rule, result type or whatever] at an SSA level and it would be applicable to the Site Collection from which the query is made.

*In other words, say I have two site collections http://foo/sites/abc and http://foo/sites/xyz, and wanted to create a rule (or whatever) at the SSA level. For this example, hard coding the URL path would mean I have to create two rules (or whatever) …one for each site collection, which clearly doesn’t scale for large environments.

*Instead, I can create just one rule and use the variable instead that would be correct and in the proper context for all site collections.”

See the write-up for a little more, or click through to the “Query Variables” page it points out. We are advised that there are probably other ways to do this, but this is how this blogger and MS employee (writing as “bspender”) has uncovered. It is nice to know there are multiple options for approaching this task. Simplicity may be overrated.

Cynthia Murrell, September 12, 2014

Sponsored by ArnoldIT.com, developer of Augmentext

Comments

Comments are closed.

  • Archives

  • Recent Posts

  • Meta