Creating SharePoint Search Scope to Find Only Documents

Requirement: End-User wants to get only documents in search results!

Solution: In brief, create a new search scope of “ContentClass” Type “STS_ListItem_DocumentLibrary”. This will filter search results with in all the documents under SharePoint document libraries.

At high level, to get filter search results by only documents, We are going to:

  1. Create a New Search Scope
  2. Add Rules to Search Scope
  3. Create New Page for Search Results
  4. Set Search Core Results Web Part Scope Property
  5. Add New Tab to Search Center, Link the Search Page crated
I assume SharePoint search service application is already in place, up and running. (if not, create it first!)

Step 1: Create a New Search Scope:

Go to Central Administration >> Manage service applications >> Search Service Application (or whatever SSA created in your environment) >> Manage >> Click on “Scopes” Link in Search Administration.

Creating SharePoint Search Scope to Find Only Documents

Click on New Scope to Create a New Scope.

How to Create SharePoint Search Scope

Give a Name to the scope. Say: “Search All Documents”. Click “OK” to create the scope.

sharepoint document search

Step 2: Add Rules to Search Scope

Add Rules to our created scope by clicking “Add rules” link next to newly created scope.sharepoint search only document libraries

  • Choose “Property Query” in Scope Rule Type. 
  • Select “contentclass” in Property Query, enter “STS_ListItem_DocumentLibrary” as property value. 
  • Choose “Include…” under behavior.
sharepoint 2010 documents search scope

On clicking “Ok” button, You will see SharePoint saying “Scope will be updated in 14 Minutes”. Fortunately, no need to wait so. Go back to Search Administration >> Click on “Start Update Now” link next to Scope Needing Update

sharepoint search multiple document libraries

Once scope updated, you can verify the scope results by checking our newly created scope.

sharepoint search scope for document library

Alright, we have the scope ready. Lets move forward to make it available to user from search center.

Step 3:Create New Page for Search Results

Go to Search Center site, Create a New Page (Don’t have Search Center created? Then create a New page in your team site of “Search Results” Page Layout type).

sharepoint search for all document library

Give it a Name. say: SearchAllDocuments.aspx

Step 4: Set Search Core Results Web Part Scope Property

Edit SearchAllDocuments.aspx page, Edit “Search Core Results” web part.

Expand the web part properties, under Location Properties >> Enter the scope as: Search All Documents (which is the name of the scope we have created in step: 1). Click “Ok” to save the changes. Publish/Check-in the page.

Go to the Search Center site >> Get the Ribbon from Site actions >> Click on “Edit” button from the ribbon

Click on “Add New Tab”

Give name to the tab, say: Search All Documents, Enter “SearchAllDocuments.aspx” (or whatever page we created in Step 3) for page field.

That’s all! Search for a keyword to see our work in action!!

sharepoint search documents only

As SharePoint 2010 supports search refinements, we can refine the results further by clicking appropriate links (e.g., “Word” under result type search refinements web part).

Using the same method, We can filter search results based on other properties supported. For all available ContentClass parameters, refer https://msdn.microsoft.com/en-gb/library/dd584327%28office.11%29.aspx. E.g. You want to get all task list items. or you may want to search only surveys or picture libraries, etc.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “Creating SharePoint Search Scope to Find Only Documents

  • This scope also returns the urls to document libraries in the search results, not just the documents… At least, that’s happening to me. Is it possible to do something about that so we only get the documents and nothing else?

    Reply
  • Great post!
    It’s possible to copy those documents to a folder for example?

    Thanks in advance.

    Mauricio

    Reply
    • Want to download all documents from search result? Use download Managers such as FDM, DownThemAll, Orbit, etc.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *