Keyword Management (FAST Search Server 2010 for SharePoint)

You can use the keyword management features in Microsoft FAST Search Server 2010 for SharePoint to provide more relevant query results to different groups of users. This includes synonyms, Best Bets and promotions of pages or sites.

Keyword terms are defined by an administrator to improve search results. When a query includes a keyword term or one of its synonyms, any recommended results in the form of Best Bets or Visual Best Bets can be returned with the query result.

Best Bets, Visual Best Bets, document promotions, and document demotions can be associated with defined user contexts. These user contexts enable administrators to recommend results that are relevant to a specific user group.

In this article:

Applies to: SharePoint Server 2010

Using User Contexts in Queries

When you create a custom search application, you must provide the user context information in the query. You can add one or more user context specifications by using the UserContext Element in Microsoft.Search.Query Schema. You add the actual context specification to the UserContextData Element.

The userContextString is a string formatted according to the following format:

K:D:v1Dv2Dv3...|K:D:v1Dv2Dv3

Table 1. User context syntax components

Syntax Component

Description

K

The keyword key (for example, "responsibilities").

If the key contains any of the special characters colon (":"), backslash ("\"), or pipe ("|"), they must be escaped.

Example: "\:"

D

The delimiter used to delimit multiple values. The first instance of the delimiter is enclosed in ":" characters, and specifies the delimiter value used in the following string. If the context string has only one value, D is left empty ("::"), which means that the key only has a single value.

The delimiter value can consist of one or more characters (a single character or a string such as ";", "$" or "STOP").

The delimiter cannot contain any special characters such as ":", "\", or "|".

v1..vx

Values for the key K. The values cannot contain the delimiter.

If the key contains any of the special characters ":", "\", or "|", they must be escaped.

Example: "\:"

|

Used to separate multiple key/value pairs.

A site administrator has defined a Visual Best Bet Dev Center to apply only if the user executing the query has the developer responsibility. In this case, the query must include the specification of the user's context, and a query for the user with this responsibility must include a userContextString as follows.

responsibilities:;:developer

Requesting Best Bets and Visual Best Bets in the Query Result

When using the QueryEx Query Web service method, you can request Best Bets and Visual Best Bets by using the IncludeSpecialTermResults element.

In the query result, you get the Best Bets and Visual Best Bets in the following tables:

  • SpecialTermResults: This table contains one row for each Best Bet defined for the keyword.

  • VisualBestBetsResults: This table contains one row for each Visual Best Bet defined for the keyword.

The two tables contain the same columns, as explained in Table 2.

Note

The set of columns returned for Best Bets is different for SharePoint Server search and FAST Search Server 2010 for SharePoint.

Table 2. Result table columns returned for Best Bets and Visual Best Bets

Column

Description

Name

The name of the Best Bet or Visual Best Bet.

Description

An optional description.

Keyword

The associated keyword. The keyword is provided in the following format:

KD[<keyword>]

Where <keyword> is the keyword that matches the query.

Teaser

A teaser text that may be used in query results.

TeaserContentType

An optional content type (e.g. text/html) for the teaser.

Uri

The URI for the Best Bet or Visual Best Bet.

For a Best Bet, this is the URI that you can display on the query result page.

For a Visual Best Bet, this is the URI to the graphical element that you can display on the query result page.

Position

The desired position of the Best Bet or Visual Best Bet in the query result. This column is only relevant when having more than one Best Bet or Visual Best Bet defined for a keyword.

Note

If you use teaser or position for Best Bets or Visual Best Bets, make sure that you create and manage the keyword settings using Windows PowerShell and not the Site Collection UI. These settings are not available in the UI.

Using Best Bets and Visual Best Bets in the Query Web Service

The following steps are an extension of Walkthrough: Querying FAST Search Server From a Client Application. Follow the steps in that article, and extend the code as described below.

The code extensions are as follows:

  • Request Best Bets or Visual Best Bets in the query XML

  • Print the Best Bets or Visual Best Bets data in the second DataGridView control

To extend the code for the Visual Studio client application

  1. Replace the definition of the queryXML2 string, to add Best Bets and Visual Best Bets in the result set:

       // queryXML2 is the part of the XML after the query string.
       string queryXML2 = @"
             </QueryText>
          </Context>
          <ResultProvider>FASTSearch</ResultProvider>
          <Range>
             <Count>10</Count>
          </Range>
          <IncludeSpecialTermResults>true</IncludeSpecialTermResults>
       </Query>
    </QueryPacket>";
    
  2. To include Best Bets in the query result, add the following code line to the queryButton_Click event:

       // Set the second DataGridView data source to the SpecialTermResults table in the DataSet object:
       secondGrid.DataSource = queryResults.Tables["SpecialTermResults"];
    
  3. To include Visual Best Bets in the query result, add the following code line to the queryButton_Click event:

       // Set the second DataGridView data source to the VisualBestBetsResults table in the DataSet object:
       secondGrid.DataSource = queryResults.Tables["VisualBestBetsResults"];
    

See Also

Reference

UserContext Element in Microsoft.Search.Query Schema

UserContextData Element

Concepts

Walkthrough: Querying FAST Search Server From a Client Application