Saturday, January 18, 2014

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.
Click on New Scope to Create a New 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.

 Step 5: Add New Tab to Search Center, Link the Search Page crated

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 http://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.

Read more: http://www.sharepointdiary.com/2013/02/creating-search-scope-find-all-documents.html#ixzz2qpDuOj8t


Reference:
http://www.sharepointdiary.com/2013/02/creating-search-scope-find-all-documents.html

No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...