Working With SharePoint 2010 Search - Part 1

In this walk through, you will learn how to customize the default SharePoint 2010 search interface by adding new tab:

a. You will add a new content source.
b. You will add a new scope and add rules for this new scope.
c. 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.
d. You will modify Search Box web part and associate it with the newly created scope. This way you will get filtered search results

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 1: 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 Scopes in the left side menu.

Figure 2: Scopes

7. Click New Scope. Enter New Search in Title field. Enter New Search Scope in Description field.

8. In Target Results Page, keep the default option Use the default Search Results Page selected. Click OK.

9. This will create a new search scope. Update Status column will show Empty and Add rules link. Click Add rules link to add rules.

10. You will see four options listed in Scope Rule Type. Keep the first one Web Address selected. In Web Address section, keep Folder option selected and enter the site you want to search in this scope. In Behavior section, keep the first option Include selected and click OK.

11. Now rules have been added. To start crawling immediately, go back to Search Administration page (General Application Settings > Farm Search Administration > Search Service Application). Under System Status, locate  Scopes needing update. You will see Start update now link against it. Click this link to start crawling immediately.

12. Now, we will add a new tab in search center to search the scope we just defined. If you have not created a search center site yet, create it now. Before we add new tab, we need to create a new page that will be used for this new tab. Open SharePoint Search Center site. Click Site Actions and select New Page.

13. Enter ScopeSearch in the New page name and click Create. It's better that you don't use spaces in the page name. If you used a space, it will be converted to '-'. ScopeSearch.aspx page will be created and stored in Pages library.

14. Now that we have created the page, we are ready to create new tab. Click Add New Tab.

Figure 3: Add New Tab

15. Enter Scope Search in Tab Name and Enter ScopeSearch.aspx in Page. ScopeSearch.aspx is the page that we created in the previous step. Click Save.

16. In this step, you will learn how to configure Search Box for use with our scope. Open Search Box's context menu and select Edit Web Part.

Figure 4: Edit Search Box

17. Expand Miscellaneous node. At the bottom you will see Scope display group field. Enter New Search in the box. This is the scope that we created above. Click OK.

18. Click Save & Close button in the ribbon.

Figure 5: Save & Close

19. Now, it's time to test the changes. Select the new tab that you just created on the search page. Enter a term in the search box and search it. You will see the related results below.

Figure 6: Test new search tab

20. Till now you have just added a new search tab and created a new search page. Now you will create a new search results page to associate with the new tab. Click Site Actions and select New Page. Enter ScopeSearchResults in the New page name box and click Create.

21. Edit Search Box web part again and expand Miscellaneous node. Locate Target search results page URL property.

Figure 7: Search results page URL

By default, it contains results.aspx. Replace it with the new page that you just created (Enter ScopeSearchResults.aspx). Click OK to apply the changes and close the web part.

22. Test the new change. Search something in the search box and the results will be displayed in the new results page. Notice the URL when you select new search tab. This is the page that got created when we added new tab.

Figure 8: New search page

This is the new search page that you created. Now enter a term in search box and search it. Again, notice the URL when the results are displayed. This is the search results page that we created and associated with this scope search.

Figure 9: New search results page

So, what is the purpose of this exercise? By defining a new scope 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 scope, you selected a particular SharePoint site. By using that particular scope in the Search Box web part, you see results only from that particular site. This is very useful. You can create tabs specially for particular sites and get filtered search results. This is particularly useful in big organizations where each department has a separate site.