Share via


How to: Federate Search to a SharePoint List

Note

This topic describes functionality that is part of the Infrastructure Update for Microsoft Office Servers. To download the update, see Description of the SharePoint Server 2007 infrastructure update: July 15, 2008.

You can create a Local Search Index location to show federated results from the search server's local search index. You could use this functionality to return federated search results from a SharePoint list targeted for particular searches in a way similar to the Best Bets functionality.

In this walkthrough, you learn how to display federated search results from a SharePoint list that is created from a Microsoft Office Excel 2007 worksheet. The steps described in this topic include the following:

  • Creating the SharePoint list

  • Creating and configuring a search scope for the list

  • Creating and mapping managed properties to the list's crawled properties

  • Creating the federated location

  • Customizing the location's display information

  • Configuring a trigger for the location

Prerequisites

Following are the prerequisites for this walkthrough:

  • You are a site collection administrator for the SharePoint site.

  • You are a search administrator for the search server.

  • You have installed Microsoft Office Excel 2007.

  • You have downloaded the following example Office Excel file for this topic: Sampleformslist.xlsx.

Step 1: Create a List

You begin by creating the list and populating it with data. To save time, you can create the list by importing data from an Office Excel worksheet.

To create the list from an Office Excel worksheet

  1. On your site's home page, click the Site Actions link, and then click Create.

  2. Select Import Spreadsheet in Custom Lists.

  3. Type CustomImportSample in the Name field.

  4. Click Browse, navigate to the location where you saved Sampleformslist.xlsx, select it, and then click Open.

  5. Click Import.

  6. Click Range of Cells in the Range Type list.

  7. In the Select Range field, type $A$1..$D$11.

  8. Click Import.

After you create the list, start an incremental crawl for the Local Office SharePoint Server sites content source to update the index with the list data.

To start an incremental crawl

  1. On the Search Administration page, click the Content Sources link in the Crawling section of the left navigation bar.

  2. On the Manage Content Sources page, point to the Local Office SharePoint Server sites content source, click the arrow that appears, and then click Start Incremental Crawl.

    Important

    Ensure that the CustomImportSample list is included in the Local Office SharePoint Server sites content source.

Step 2: Create a Search Scope

You must create the search scope for the CustomImportSample list. This step includes the following tasks:

  • Creating the search scope and configuring the scope rules

  • Compiling the search scope and verifying that the compilation worked

To create a scope for the list

  1. On your site's home page, click the Site Actions link, and then click Site Settings.

  2. Click Search scopes in Site Collection Administration.

  3. On the View Scopes page, click New Scope.

  4. In the Title field, type SampleListScope, and then click OK to create the scope.

  5. On the View Scopes page, click SampleListScope to open the Scope Properties and Rules page.

  6. Click New rule in the Rules section.

  7. In the Scope Rule Type field, click Web Address (https://server/site).

  8. In the Web Address field, click Folder, and then type http://SiteURL/lists/customimportsample.

    Replace SiteURLwith the URL path for your site.

  9. In the Behavior field, click Require - Every item in the scope must match this rule.

  10. Click OK to add the rule.

  11. Click New rule in the Rules section.

  12. In the Scope Rule Type field, click Property Query (Author = John Doe).

  13. In the Property Query section, click contentclass from the Add property restrictions list.

  14. Copy the following text into the Property Query text field:

    STS_ListItem_GenericList

    Note

    STS_ListItem_GenericList is the content class for a list item. You add this restriction to the scope so that the scope includes only items from the list, not the list itself. If you do not include this restriction, the CustomImportSample list is always returned as the first result.

  15. In the Behavior field, click Require - Every item in the scope must match this rule.

  16. Click OK to add the rule.

    The Custom Import Sample List scope does not contain any items until it is compiled successfully.

To compile scopes and verify that compilation succeeded

  1. On the Search Administration page, in the System Status section, click Start update now for the Scopes needing update row.

  2. On your site's home page, click the Site Actions link, and then click Site Settings.

  3. Click Search scopes in Site Collection Administration.

  4. Ensure the Items field value for Custom Import Sample List is 10.

Step 3: Map Crawled Properties

You map the CustomImportSample list's crawled properties to managed properties by performing the following tasks:

  • Mapping a crawled property to an existing managed property

  • Mapping a crawled property to a new managed property

  • Starting a full crawl of a content source

To map a crawled property to an existing managed property

  1. On the Search Administration page, under Queries and Results, click Metadata properties.

  2. In the Managed Properties view, click Description in the Property Name column to open the Edit Managed Property page.

  3. In the Mappings to crawled properties section, click Add Mapping.

  4. In the Select a category list, click SharePoint.

  5. In Crawled property name, type form, and then click Find.

    This returns the crawled properties for the CustomImportSample list.

  6. Select the ows_FormDescription(Text) property, and then click OK.

  7. Click OK to save your changes to the Description managed property.

To add the managed properties

  1. On the Search Administration page, under Queries and Results, click Metadata properties.

  2. In the Managed PropertiesView list, click New Managed Property.

  3. For the Name and type section, type formid in the Property name field, and then click Text.

  4. In Mappings to crawled properties, click Add Mapping.

  5. In the Select a category list, click SharePoint.

  6. In Crawled property name, type Form, and then click Find.

    This returns the crawled properties for the CustomImportSample list.

  7. Select ows_FormID property, and then click OK.

  8. Click OK to create the formid managed property.

    Note

    These property changes are applied after the search service completes another full crawl of the content source.

To start a full crawl

  1. On the Search Administration page, click the Content Sources link in the Crawling section.

  2. On the Manage Content Sources page, point to the Local Office SharePoint Server sites content source, click the arrow that appears, and then click Start Full Crawl.

After the full crawl completes, verify that the managed properties are mapped correctly to the crawled properties, and are populated with the data from the CustomImportSample list.

To confirm that the managed properties are mapped correctly

  1. On the Search Administration page, under Queries and Results, click Metadata properties.

  2. On the Metadata Property Mappings page, in the Managed Properties View list, click formid in the Property Name column.

  3. In the Content using this property section, verify that 10 is displayed for Number of items found with this property.

Step 4: Add the Federated Location

You add the federated location for the CustomImportSample list by performing the following tasks:

  • Adding the federated location

  • Testing the federated location

To add the federated location

  1. On the Enterprise Search Administration page, click Federated Locations, and then click New Location.

  2. In the Location Name field, type CustomListSampleResults.

  3. In the Display Name field, type Custom List Sample Results.

  4. In the Description field, type text to describe the location, such as Results from a custom SharePoint list.

  5. For the Location type field, click Search Index on this Server.

  6. In the Query Template field, type {searchTerms} scope:SampleListScope.

  7. In the "More Results" Link Template field, type http://SiteURL/lists/customimportsample/AllItems.aspx.

    Replace SiteURL with the URL path for your site.

  8. Click OK to add the location.

Test how results are returned from the federated location you just created to confirm that it is configured correctly.

To test the federated location

  1. In your browser, navigate to the results page URL. For example, navigate to http://SiteURL/results.aspx. Replace SiteURL with the URL path for your site.

  2. Click the Site Actions link, and then click Edit Page.

  3. In the Right Zone, click Add a Web Part.

  4. In Suggested Parts for Right Zone, click Federated Results, and then click Add.

  5. Click the edit arrow for the new Federated Results Web Part to display the Web Part menu, and then click Modify Shared Web Part. The Federated Results Web Part tool pane opens.

  6. In Location Properties, click Custom List Sample Results in the Location list.

  7. Click OK.

  8. Click Exit Edit Mode to close the Edit page.

  9. In the search box, type a search term found in the list of items, such as form, and then click Go.

    You should see results from the CustomImportSample list displayed in the Federated Results Web Part; the default display XSLT is used to display the list item results.

In the next step you modify the default display information for the federated location to customize the results view.

Step 4: Customize the Display Information for the Federated Location

To display additional properties in the federated results, you must customize the display information for the federated location. To do this, you perform the following tasks:

  • Customizing the location's Properties element to return the formid managed property

  • Customizing the location's XSL element to display the value from the formid managed property

To customize the location's Properties element

  1. On the Search Administration page, in the Queries and Results section, click Federated Locations.

  2. On the Manage Federated Locations page, click Custom List Sample Results.

  3. On the Edit Federated Location page, in the Display Information section, clear the Use Default Formatting check box for Federated Search Results Display Metadata.

  4. Click the ellipsis button (…) for the Properties field to open the Text Entry window for the location's Properties element.

  5. Replace the default XML with the following code.

    <Columns>
      <Column Name="title"/>        
      <Column Name="path"/>
      <Column Name="description"/>
      <Column Name="contentclass"/>
      <Column Name="formid"/>
    </Columns>
    

    The modified XML removes the hit highlighting-related Column elements and adds a Column element for the formid managed property.

  6. Click OK to close the Text entry window.

To customize the location's Xsl element

  1. Click the ellipsis button (…) for the XSL field to open the Text Entry window for the location's Xsl element.

    You can modify the XSLT directly in this window; however, you might find it easier to copy the code to a file. You can then edit that file by using an application such as Microsoft Visual Studio 2008 or Microsoft Office SharePoint Designer 2007. After you finish editing the file, you can copy the modified code into the Text Entry window and save your changes to the federated location.

  2. Define a new template, GetTitleWithFormID, by adding the following code before the closing stylesheet tag, </xsl:stylesheet>:

    <xsl:template name="GetTitleWithFormID">
      <xsl:value-of select="title"/>:  
        <xsl:value-of select="formid"/>
    </xsl:template>
    
  3. Search for the xsl:call-template element that applies the GetTitle template. You can find it by searching for the following code.

    <xsl:call-template name="GetTitle">
    
  4. Replace GetTitle with GetTitleWithFormID, as follows.

    <xsl:call-template name=" GetTitleWithFormID ">
    
  5. Click OK to close the Text Entry window.

  6. Click OK to save your changes to the Custom List Sample Results federated location.

    Test viewing the location's results again to confirm that your changes worked.

  7. Browse to your search server's site, and in the search box, type a search term found in the list of items (for example, form), and then click Go.

    You should see results from the CustomImportSample list displayed in the Federated Results Web Part. The custom display XSLT is used to show the list item results, with the formid value appended to the title in the following format: title: formid.

Step 5: Specify a Trigger for the Federated Location

The Custom List Sample Results location configuration is currently configured to pass all queries to the federated location. To limit the number of queries sent to the federated location, you can specify a trigger. A trigger is a query constraint that determines when to pass a query. Triggers for a location ensure that only those queries that match the pattern specified for the triggers are forwarded to the federated location.

To specify a trigger for the federated location

  1. On the Search Administration page, in the Queries and Results section, click Federated Locations.

  2. On the Manage Federated Locations page, click Custom List Sample Results.

  3. In the Trigger section of the Edit Federated Location page, click Prefix: Query must begin with a specified prefix.

  4. In the Add Prefix field, type form, and then click OK to save your changes.

    Test viewing the location's results again to confirm that your changes worked.

  5. Browse to your search server's site. In the search box, type the search term form which you tested in the previous step, and then click Go.

    This time, no search results are displayed in the Federated Results Web Part because when you specify a prefix trigger for a location, the prefix is not passed in the query.

  6. Test another search term, but now use the prefix. In the search box, type form benefits, and then click Go.

    All the items from the list containing the term benefits are returned.

  7. Test the same search term, this time without the prefix. In the search box, type benefits, and then click Go.

    No results are displayed in the Federated Results Web Part.

See Also

Concepts

Federated Search Overview
Federated Results Web Parts XSLT