A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Saturday, August 2, 2014

SharePoint 2013 Search - Part 1

In this Article:

  • Result Sources
  • Federated Search
  • Setup Bing Search
  • Search External Data Sources
  • Setup File Shares Search

SharePoint enterprise search is regarded as one of the world’s best search technologies. SharePoint 2013 has gone one step farther and added new enhancements to this world-class technology. There are new enhancements for finding people and expertise. Phonetic search works in multiple languages. Search results display authored documents and information about past projects that can showcase a person’s expertise. There are contact cards that provide a way to contact people directly from the search results.


Navigation has been enhanced so that users can find search box quickly. Search results are logically grouped and provide query suggestions. Search center sites can be created that focus on a particular scope. Scopes can be added in the central administration to limit the search to particular areas. By the way, the terminology has slightly changed in SharePoint 2013. Search scopes in SharePoint 2010 are now called as Result Sources in SharePoint 2013. Administrator can define a result source. Local SharePoint is the default predefined result source. With a result source, administrator can restrict queries to a subset of content by using a query transformation. You can use a query transformation to return on video results from the local SharePoint index.

One big improvement is the search result preview. Users can rest the pointer over a search result to preview the document content in the hover panel to the right of the result.

Figure 1: Hover panel 

Certain types of related results are displayed in groups called result blocks.
A result block contains a small subset of results that are related in a particular way.

Search helps users quickly return to important sites by remembering what they have previously searched.

Site owners can create result types. A result type is a rule that identifies a type of result and a way to display it.

Well, these were some of the new enhancements in SharePoint 2013. In this chapter, you will learn how to customize the default SharePoint search interface by adding new search and result pages.
  • You will add a new content source.
  • You will add a new scope (result source) and add rules for this new scope.
  • You will add a new tab in the search center on your SharePoint site and create search pages for this tab. You will create two pages, one that will host the Search Box web part and the other will be used to display filtered search results.
  • You will modify Search Box web part and associate it with the newly created scope. This way you will get filtered search results.
First you will create new result source. This result source will be used in the custom results page that you will create. 

Result Source For Custom Search

1. Open SharePoint Central Administration.
2. Click General Application Settings.
3. Click Farm Search Administration.
4. Click Search Service Application.
5. On the left hand side, click Content Sources under Crawling.


Figure 2: Content Sources

By default, Local SharePoint sites content source is already created. If you have not indexed your content before, you can do it now. Hover your mouse over Local SharePoint sites, a drop down will appear. Left-click it to open the menu and select Start Full Crawl from the menu. If there is no content in your sites, it will take 2-3 minutes for the engine to finish the crawl. You can create new content sources in this section. Once the indexing is complete, you can go and test search in your SharePoint sites. To view crawl log, hover mouse over Local SharePoint sites and open menu and then select View Crawl Log. Here you can see each content source and number of successful crawls, errors, warnings, top level errors and deletes against each content source.

6. Click Result Sources in the left side menu.


Figure 3: Result Sources (Scopes)

7. Click New Result Source. Enter New Search in Name field. Enter New Search Scope in Description field. In Protocol, keep Local SharePoint selected. In Type, keep SharePoint Search Results selected. In Query Transform, keep default option selected. To build a new query transformation, click Launch Query Builder. Remove text from the Query text box. Select Query from the search box from Keyword filter drop down and click Add keyword filter button. Select --Show all managed properties-- from the Property filter. Again open Property filter and select Created. Select Less than in the comparison drop down. Select Today’s date (~5 days) from the value drop down. Click Add property filter button. This query will return all items that were created before today’s date. Click OK.

Figure 4: Build Your Query

In Credentials information, keep Default Authentication selected. Click Save button to save the settings.

8. Go to SharePoint site and create a search center site. Go to Site Actions > Site Contents. In Subsites section, click new subsite. In Title enter Custom Search Center. In URL name enter customsearch. In Template Selection section, select Enterprise tab and select Basic Search Center. Click Create button.

9. Go to the newly created site. Go to Site Settings > Site Contents. Go to Pages library. If you don't see Pages library that’s because you have not enabled SharePoint Server Publishing feature in Site Settings. To enable that feature in site settings, first you have to enable SharePoint Server Publishing infrastructure feature in site collection features. Select FILES tab. Click New Document button. Enter Custom Search in Title. Enter csearch in URL Name. Default selection in Page Layout is (Article Page) Body only. Click Create.

10. Add search web part to the page. Click EDIT from the top right corner. Click INSERT tab. Click Web Part button. Select Search from Categories. Select Search Box from the Parts. Click Add button. 

11. Go to web part properties. Select Send queries to a custom results page URL. In Results page URL, enter csearchresults.aspx. If you are not sure about the path, enter complete path, for example, http://site/searchcentersitename/Pages/csearchresults.aspx. Remove the querystring that is appended automatically after the page name. Click OK. This page has not been created yet. You will create this page now.

12. Create another page following the instructions given above. Name it Custom Search Results and enter csearchresults.aspx in the URL. 

13. Go to the new page. Edit it and add a web part following the instructions given above. This time add Search Results web part. After adding the web part, edit its properties. Click Change Query button.  In the Select a query drop down, select the result source (New Search (Service)) you created in the previous steps.  In the Keyword filter, select Query from the search box. Click OK

14. Go to the custom search page (csearch.aspx) and try to search for an item. Results will be shown on the custom results page with the results matching the criterion you set in the result source.


Figure 5: Custom results page
So, what is the purpose of this exercise? By defining a new results source you have basically filtered the search results. Now, instead of getting all search results, you will get only what is relevant. Remember, when you defined the results source, you added a filter to show you only the items that were created before today’s date. By using that particular results source in the Search Results web part, you see only filtered results. This is particularly useful in big organizations where each department has a separate site and each site has a huge volume of documents. You can create small search centers that use specific results sources to filter the results.

No comments:

Post a Comment