Exercise 3: Using a Custom Ranking Model

Custom Ranking Models are used in conjunction with the Core Results Web Part. The Core Results web part has a DefaultRankingModelID property that takes the ID of the ranking model to use. Unfortunately, this property is not exposed in the property pane. Therefore, you have to add the property into the *.webpart file.

  1. Navigate to the ImportantTasksResults.aspx page either directly or by running a query.
  2. Select Site Actions » Edit Page to place the page in edit mode.
  3. On the Search Box Web Part, select Export from the Edit menu.

    Figure 1

    Export the Search Box web part

  4. Save the file to your desktop.
  5. Open the exported file in Visual Studio 2010 for editing.(Note: you will need to open Visual Studio 2010 first, then in the File menu » Open » File… and select the Search_Box.dwp file found on your desktop)
  6. Within the file, add a new property as follows to have the Core Results Web Part utilize the new ranking model (the GUID is the ID of the ranking model to use):

    <DefaultRankingModelID xmlns="urn:schemas-microsoft-com:SearchBoxEx">c978ef2b-300a-444b-af9a-d51261294587</DefaultRankingModelID>
  7. (Note: add this just before the </WebPart> tag at the end of the file).
  8. Save the file and return to the Search Center site at https://intranet.contoso.com/sites/Lab11/searchcenter. (Note: this should still be open from earlier).
  9. With the ImportantTasksResults.aspx page still in edit mode, place a check in the web part’s top right corner checkbox to select the web part. Then select Insert » Web Part from the ribbon. If the Insert tab is not visible, select the Top Zone. This should make the Insert tab visible.
  10. Select Upload a Web Part and upload the modified file:

    Figure 2

    Upload the modified Search Box web part

  11. Drop the modified file on the page. (Note: make sure you are using the newly uploaded copy found in Imported Web Parts and not the original found in the Search folder.)
  12. Remove the original Search Box web part from the page (i.e. use the Search Box [1] drop down arrow in the web part’s top right corner to select Delete).
  13. In the newly added Web Part that contains the search box, click the Web PartMenu drop down arrow in the right upper corner of the web part and pick Edit Web Part.
  14. In the Search Box task pane, expand the Miscellaneous section. Change the Target search results page URL from ImportantSearchResults.aspx to ImportantTasksResults.aspx and click OK at the bottom of the task pane.
  15. Now check the page in to save your changes. You can find the Check in button on the Page tab.
  16. Verify that your new ranking model is working by entering Team as a search term into the Search box.
    Note:
    In this exercise you implemented the custom ranking model you created in the previous exercise.