Subscribe to Windows IT Pro
March 27, 2008 12:00 AM

Customize Search Features in Microsoft Office SharePoint Server 2007

MOSS gives site admins the tools to target searches to users' needs
Windows IT Pro
InstantDoc ID #98283
Rating: (6)

Customize Search Results
By default, the Search Center displays results in the results.aspx page. You can customize this page or create your own results page. For example, consider the document library with the custom Color Category field. When a user searches against the Catalog scope, you want the search results page to display a field named Color Category. You can achieve this by modifying the XSL markup of the Search Core Results Web part in the search results page.

Start by performing a search with the Catalog scope so that you get a results page where only items that fall within the Catalog scope are displayed. After you have such a page, follow these steps to create a new search results page:

  1. Click Site Actions, Create Page.
  2. Enter a Title (e.g., Catalog Results) and a URL Name (e.g., catalogresults.aspx) for the new page.
  3. Select the (Welcome Page) Search Results Page layout, then click Create.

    After step 3, you’ll see the catalogresults.aspx page in edit mode, which shows its various Web parts. Search Core Results is the Web part that displays the search results. You need to modify this Web part to include the Color Category column in the search results view. In the Search Core Results Web part, click edit, Modify Shared Web Part. This action displays the Web part properties tool pane. As Figure 4 shows, the tool pane contains the following categories:
    Results Display/Views—In this section, you specify search results to display per page, sentences to show in the results display, and so forth.
    Results Query Options—This section lets you specify options such as duplicate results removal, search term stemming, and noise word inclusion. Word stemming matches a search word with its grammatical variants; for example, the word crawl stems to crawls, crawled, crawler, and so forth. Noise words, also known as stop words, are words that aren’t significant indicators for content, such as the word the.
    Fixed Keyword Query—This section lets you enter a specific keyword to automatically include with every search
    Miscellaneous—Here you can narrow the scope of search results, and also choose options such as Show Action Links, Display “Alert Me” Link, Display “RSS” Link, and so forth.
    Below these categories, you’ll find the Data View Properties section, which contains the XSL markup that controls the HTML to render the search results dataset. So, to continue the process of customizing the results page:
  4. Expand the Results Query Options category.
  5. Add the following line of XML to the Columns node in the Selected Columns text box, then click OK:
     Column Name=”ColorCategory”/>
    Remember that we’ve already defined the ColorCategory column. The SharePoint search engine returns data internally in XML format. This XML data is transformed to an HTML view through XSL markup.
  6. Under the Data View Properties section, click XSL Editor to display the Text Entry dialog box with the XSL markup that renders the XML results into HTML.
  7. Copy the XSL markup to an external text editor, such as Microsoft Office Share- Point Designer 2007. SharePoint Designer is a WYSIWYG editor, so it helps you visualize the results of the XSL code as you edit.
  8. Locate the result template node in the markup; its first line looks like this:
     xsl:template match=”Result”>  
  9. Add the following before the line
     Color Category: xsl:value-of
      select=”colorcategory” />
    Note that the value colorcategory is written in all lower case, regardless of how it was written in metadata property mapping.
  10. Copy and paste the entire XSL markup back into the Text Entry dialog box, then click Save.
  11. Click OK to save changes to the XSL markup and the Web part.

Now when you perform a search using the search box, you’ll see the Color Category property exposed in the search results area. By following these steps, you can expose any property that’s already stored in the metadata

Control SharePoint Searches
You should now have a good idea of how you can customize the search experience in MOSS 2007. The procedures shown in this article, though simple, can easily be leveraged to create more meaningful business solutions that can crawl and index a large amount of disparate data, yet offer end users targeted search capabilities to zero in on a specific subset of data. Custom search scope definitions also let administrators schedule indexing and crawling of each scope separately: Only scopes with frequently changing contents need to be crawled frequently. This ability not only saves server resources, but it also makes the search results more accurate and fresh.

Related Content:

ARTICLE TOOLS

Comments
  • blarg1234
    4 years ago
    Jul 02, 2008

    efsaefee

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.