How to search only to some specific Libraries in SharePoint 2013?

Hi all,

How can we put filters to search box so that it searches documents only to some specific Libraries in SharePoint 2013?

Please suggest for it?

September 13th, 2013 8:38am

You can use KQL property restrictors to do this: http://msdn.microsoft.com/en-us/library/office/ee558911.aspx

You can use the "path" restrictor.  So in the search box you could put something like this:

terms to search for path:http://SERVER/SITE/LIBRAY

The "path:http://SERVER/SITE/LIBRAY" part of the query tells the search engine to look for the search terms only under the path given, and any of its children.

If you want to go further, you could define a custom result source (search scope) to limit queries to this library and then have a custom page to render those results.  Check this post for info on that: http://brandonatkinson.blogspot.com/2013/07/setup-multiple-search-pages-result.ht

September 13th, 2013 11:37am

I want to search documents within 4 libraries together.
September 13th, 2013 11:51am

KQL supports multiple restrictors, so you could do something like this:

terms to search for path:http://SERVER/SITE/LIBRAY1 path:http://SERVER/SITE/LIBRAY2 path:http://SERVER/SITE/LIBRAY3 path:http://SERVER/SITE/LIBRAY4
Now, to be honest I have not tried that before, but its easy to test, just copy that line and put it in the search box and verify the results are correct.

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2013 12:00pm

I am unable to find out where to put Path restrictor in Search box? Please tell in detail.
September 13th, 2013 12:07pm

Did you try adding content sources to the scope. The lists you need could be added as folder paths. For example if list is ABC set path as http://localhost/sites/Sitename/ABC. Then you have to crawl the content sources you make. In the web part set the scope.
Free Windows Admin Tool Kit Click here and download it now
September 16th, 2013 12:37pm

I am new in Search part of SharePoint. Please elloborate where I have to set scope for Path in Webpart. I have tried to restrict by app URL but with that I see that there is only one option to keep URL. I want to restrict for 4 libraries i.e. I need to restrict for 4 paths. How can I achieve this?
September 16th, 2013 1:04pm

Hi.. I have tried to apply query in Search Results web part as shown below:

{SearchBoxQuery}( (Path:http://sharepoint/sites/demo/dev/DocLib1 (FileExtension:pdf)) OR
(Path:http://sharepoint/sites/demo/dev/DocLib2 (FileExtension:pdf)) OR
(Path:http://sharepoint/sites/demo/dev/DocLib3(FileExtension:pdf)) )
The above query works to restrict the search upto to 3 document libraries. But when no text is entered in search box then it displays all documents in all three  document libararies. I dont want to show any document if search box is empty. Can do something for it? or can we hide search result page is search box is empty? But how?
  • Proposed as answer by Tarek Yehia Saturday, September 21, 2013 3:00 PM
Free Windows Admin Tool Kit Click here and download it now
September 21st, 2013 4:03am

Your requirement to ignore a search text variable when empty is actually quite easy to implement. All you have to do is to add a question mark and the end in a curly bracket:

{searchTerms?}

Hope this helps!

  • Proposed as answer by Lukas_UK Friday, January 24, 2014 2:25 PM
January 24th, 2014 2:24pm

This works for me in O365:

path:"https://siteURL.com/DocumentLibraryName/*"

But this does not:

path:https://siteURL.com/DocumentLibraryName/*

Nor does this:

"path:https://siteURL.com/DocumentLibraryName/*"
Note the quotations.

  • Edited by Tracy'S 2 hours 46 minutes ago
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 12:36am

This works for me in O365:

path:"https://siteURL.com/DocumentLibraryName/*"

But this does not:

path:https://siteURL.com/DocumentLibraryName/*

Nor does this:

"path:https://siteURL.com/DocumentLibraryName/*"
Note the quotations.

  • Edited by Tracy'S Sunday, September 13, 2015 4:33 AM
September 13th, 2015 4:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics