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

    Question

  • 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?

    Friday, September 13, 2013 8:38 AM

All replies

  • 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.html


    Brandon Atkinson
    Blog: http://brandonatkinson.blogspot.com


    • Edited by Brandon Atkinson Friday, September 13, 2013 11:38 AM Added code block for emphasis
    Friday, September 13, 2013 11:37 AM
  • I want to search documents within 4 libraries together.
    Friday, September 13, 2013 11:51 AM
  • 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.


    Brandon Atkinson
    Blog: http://brandonatkinson.blogspot.com

    Friday, September 13, 2013 12:00 PM
  • I am unable to find out where to put Path restrictor in Search box? Please tell in detail.
    Friday, September 13, 2013 12:07 PM
  • 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.
    Monday, September 16, 2013 12:37 PM
  • 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?
    Monday, September 16, 2013 1:04 PM
  • 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
    Saturday, September 21, 2013 4:03 AM
  • 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
    Friday, January 24, 2014 2:24 PM
  • 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
    Sunday, September 13, 2015 4:33 AM