Chapter 6. Search Configuration

After completing this chapter, you will be able to

  • Manage FS4SP functionality in SharePoint, in Windows PowerShell, and through .NET code.

  • Manage your index schema and tune relevance.

  • Set up full-text indexes, rank profiles, content collections, and search scopes.

  • Use the out-of-the-box property extractors.

  • Add keywords with synonyms, best bets, visual best bets, and user contexts.

You can manage many features of Microsoft FAST Search Server 2010 for SharePoint (FS4SP) from within Microsoft SharePoint. However, many more feature-control switches and settings are hidden in configuration files on the FS4SP farm. This chapter covers the importance of Windows PowerShell. It also looks into how to manage your search engine on a daily basis and how to tune it to suit your specific business needs. Additionally, the chapter describes the tools available to monitor and analyze the health of the system and explains what you should do to properly back up your solution.

Overview of FS4SP Configuration

FS4SP is a great leap forward compared to pre-Microsoft FAST technology. It combines the convenience of being able to administer the key components from within SharePoint and the power of advanced management with file-level configurations. Although you can change many settings in Central Administration in SharePoint, more-advanced settings are available via the FS4SP configuration files. Beyond that, you can use Windows PowerShell for advanced, yet simple, control of the search system. Finally, Microsoft .NET customization capabilities offer you full control.

Most IT pros who worked with previous versions of FAST technology would agree that FS4SP is an advance in terms of administration. Configuring the solution is more streamlined than before, and there are fewer interaction points and technologies that you need to be concerned about.

However, some aspects of FS4SP can feel unorthodox to a Microsoft professional. For example, the FAST Search specific connectors require a Java run-time environment, and the indexing pipeline is still heavily based on Python. But all in all, FS4SP has come a long way in terms of streamlining the technology to fit into the Microsoft technology stack.

On a high level, FS4SP administration has five main methods, which are described briefly in Table 6-1. The rest of this chapter expands on the administration methods. Where appropriate, this chapter provides examples of how to manage FS4SP through SharePoint Central Administration, by using Windows PowerShell, and by writing .NET code.

Note

The sections in this chapter show administration samples that use SharePoint Central Administration, Windows PowerShell, and .NET code. Where SharePoint samples are missing, the capability is missing in SharePoint. For all Windows PowerShell samples, there is a .NET equivalent, but because using Windows PowerShell is very similar to .NET in many cases, some .NET samples have been omitted. Many Windows PowerShell cmdlets return .NET objects, and the methods executed on them are the same.

Table 6-1. Operation interaction points

Interaction point

Example of a typical operation

SharePoint

Adding a new content source; for example, setting up a crawl of a SharePoint site collection

Windows PowerShell

Tuning the index schema; for example, changing relevance weights of managed properties

Code

Managing crawled properties from a custom application

Configuration files

Registering a third-party IFilter or configuring the FAST Search specific connectors

Command-line tools

Starting or stopping internal FS4SP processes, retrieving statistics of search nodes, and so on

SharePoint Administration

You perform most basic FS4SP configuration in SharePoint Central Administration, on the FAST Content SSAs and the FAST Query SSAs. This includes setting up and managing new content sources and managing crawled and managed properties. If you are using the FS4SP Web Parts—the Enterprise Search Web Parts—you, of course, also spend time configuring those through SharePoint.

In addition to the administration settings in Central Administration, you can find administration settings on each SharePoint site collection, including administration of keywords for synonyms, best bets, and visual best bets, and administration of document and site promotions.

Windows PowerShell Administration

In addition to the administrative tasks you can manage through Central Administration or Site Collection Administration in SharePoint, you can do even more through Windows PowerShell. Most Windows PowerShell commands that target FS4SP execute in the Microsoft FAST Search Server 2010 for SharePoint shell (FS4SP shell), but a few commands must be run from the SharePoint 2010 Management Shell (SharePoint Management Shell). One example of the latter is when you want to create a new content source. Content Sources are a SharePoint Enterprise Search concept used by FS4SP. Therefore, managing content sources from Windows PowerShell is available only from the SharePoint Management Shell.

In general, if a Windows PowerShell cmdlet has the word FASTSearch as part of its name, you need to execute the cmdlet in an FS4SP shell on an FS4SP server; otherwise, you should execute it in a SharePoint Management Shell on a SharePoint server.

Note

Some of the FS4SP command-line utilities and Windows PowerShell scripts require elevated privileges in order to run. Right-clicking the shell shortcut and choosing Run As Administrator provides the permissions you need. Modifying the shortcut to always run as administrator simplifies management because you then always have the required permissions to execute any FS4SP-related command or script. You can also make sure the logged-in user executing the Windows PowerShell cmdlets is a member of the FASTSearchAdministrators local group on the server, as specified during installation.

Windows PowerShell has more than 80 different FS4SP-related cmdlets. They are roughly divided into these groups:

  • Administration

  • Index schema

  • Installation

  • Spell-tuning

  • Security

You will read about many of these in this chapter and, where appropriate, throughout the book. A convenient way to list all available cmdlets is to run the following command in an FS4SP shell.

Get-Command -Module Microsoft.FASTSearch.PowerShell

The cmdlets are all documented according to the Windows PowerShell documentation standard. To see a detailed manual page, you can prefix a cmdlet with Get-Help, for example, Get-Help New-FASTSearchMetadataCategory). Many cmdlets also show example usages, such as Get-Help New-FASTSearchMetadataCategory –examples.

Tip

You can list and group all cmdlets by name by using the following Windows PowerShell command.

gcm -Module Microsoft.FASTSearch.PowerShell | sort noun,verb | group noun | ft –AutoSize

For a complete list of Windows PowerShell cmdlets, go to http://technet.microsoft.com/en-us/library/ff393782.aspx.

Code Administration

If you are building a large search solution, you might find yourself in a situation where you want to modify certain FS4SP features or settings from code running within a custom-built application. The good news is that everything you can do from Windows PowerShell is available using .NET code. The bad news is that it isn’t always easy. For a good example, see the Crawled and Managed Properties section in this chapter; compare how easy it is to map a crawled property to a managed property in Windows PowerShell versus the number of lines of code required to do the same operation in Microsoft Visual C# or Microsoft Visual Basic.

Using the .NET API is a good option for deployment scenarios: Instead of executing a Windows PowerShell script, you can create crawled and managed properties when a SharePoint feature activates. Depending on your deployment regime, you can choose the option that fits best.

Code Example Assumptions

The code examples in this chapter assume that:

  • You are developing in Microsoft Visual Studio 2010 using Microsoft .NET Framework 3.5.

  • The application runs locally on the FS4SP administration server.

    More Info

    For information about setting up an administration server, see Chapter 4.

  • The user executing the application is a member of the local FASTSearchAdministrators group on the FS4SP administration server.

When you work with administration via the .NET API, several context classes serve as entry points for different administrative operations, as listed in Table 6-2. Later in this chapter, you see examples that use some of these classes.

Important

If you are developing on a machine that has SharePoint and not FS4SP installed, you will find the DLLs to reference at %CommonProgramFiles%Microsoft SharedWeb Server Extensions14ISAPI rather than at <FASTSearchFolder>in.

Table 6-2. Class entry points for working with the .NET administration objects

Class name

Description

MSDN reference

CompiledDictionaryContext

Used when compiling dictionaries added to FS4SP to an internal FS4SP format.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.compileddictionarycontext.aspx

ContentContext

Used to work with FS4SP content collections. Internally used by (for example) the cmdlet New-FASTSearchContentCollection.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.contentcontext.aspx

DeploymentContext

Used to deploy resources in the FS4SP farm (for example, uploading property extraction or spell-checking lists to FS4SP).

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.deploymentcontext.aspx

EntityExtractorContext

Used for property extraction inclusion and exclusion list functionality.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.entityextractorcontext.aspx

KeywordContext

Used for search keyword management functionality (for example, search setting groups, best bets, and synonyms).

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.keywordcontext.aspx

LinguisticManagerContext

Used to get access to the Linguistic manager. The Linguistic manager can be used to get the dictionary type.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.linguisticmanagercontext.aspx

PersistedDictionaryContext

Used for persisting property extractor and spell-checking dictionaries in a PersistedDictionaryCollection object.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.persisteddictionarycontext.aspx

SchemaContext

Used to work with index schema functionality like crawled and managed properties, full-text indexes, and rank profiles.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.schemacontext.aspx

SpellCheckerContext

Used for the spell-check exclusion list functionality.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.extended.administration.spellcheckercontext.aspx

If you want to integrate with FS4SP by using code that runs within SharePoint, you need to connect to the FS4SP administration service by using a proxy to the FAST Query SSA. The following code gives an example on how to get a reference to the SchemaContext object via the FAST Query SSA proxy.

var ssaProxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.
GetProxy(SPServiceContext.Current);
if (ssaProxy.FASTAdminProxy != null)
{
    var fastProxy = ssaProxy.FASTAdminProxy;
    SchemaContext schemaContext = fastProxy.SchemaContext;
    // your code here
}

Other Means of Administration

In addition to SharePoint Central Administration, Windows PowerShell, and .NET code for FS4SP management, you need to use both configuration files and command-line tools found locally on the FS4SP servers for administration of certain parts of FS4SP.

  • Configuration files. If you are moving from an older FAST incarnation to FS4SP, you might notice that the number of configuration files has gone down drastically. But many low-level settings are still available only by editing files, whether plain text files or XML. However, you can edit only 16 configuration files without leaving your system in an unsupported state, and these are all XML files; 6 of these files are related to the FAST Search specific connectors. However, there are many other interesting files, which can be tweaked to change functionality. Although these changes are unsupported, you might explore making changes to a few of these because they may be useful in some cases.

    Important

    If you leave your system in an unsupported state and you need to contact Microsoft for support on your FS4SP installation, Microsoft can decline to help you because you have modified files that are not supposed to be changed.

  • Command-line tools. Many FS4SP operations are run and controlled with command-line tools—that is, the applications that live in the <FASTSearchFolder>in folder and are available from within the FS4SP shell. All in all, there are 25 of these tools; we touch on the most important of these throughout the book.

    You need to understand the difference between these command-line tools and the Windows PowerShell cmdlets mentioned in the section Windows PowerShell Administration earlier in this chapter. Windows PowerShell cmdlets are communicating with FS4SP via the FASTSearchAdminServices Windows Communication Foundation (WCF) service, whereas the command-line tools are talking directly with different FS4SP components via an internal API. Command-line tools can be run both from a command prompt and from an FS4SP shell.

More Info

For more information about command-line tools, go to http://msdn.microsoft.com/en-us/library/ee943520.aspx.

Index Schema Management

In FS4SP, like in all search engines, the index constitutes the physical and logical core of the solution. Physically, the index is often spread out onto several machines for scale and redundancy. Logically, the index configuration defines how searches should behave and what features are activated.

In this chapter, you learn how to work with the index configuration to tailor the search experience to your business requirements.

Note

This chapter focuses on the logical aspect of the index. See the procedure “Modify the index topology” in Chapter 5, for information about physical operations, such as how to scale and how to redistribute the index to new servers.

The Index Schema

The very heart of FS4SP is the index configuration, or the index schema. Read Chapter 2, for a walkthrough of all concepts related to the index schema: how these concepts relate to one another and what their purpose is. This chapter describes how to work with and adapt the index schema to your needs.

In previous incarnations of FAST technology, the index schema is an actual configuration file. Previously, you edited this file by hand and deployed it onto the system to apply the changes. In FS4SP, this procedure has been revamped and is now hidden behind more user-friendly tools. These tools modify the internal configuration file for you, reducing potential configuration errors introduced by manual editing.

As previously mentioned, the index schema is internally stored in a configuration file. If you are curious about how this file looks, it is available at <FASTSearchFolder>index-profilesdeployment-ready-index-profile.xml. Do not change this file directly unless you know exactly what you are doing and are sure you want to make this unsupported change. Your index might become corrupt, and you can render your system unusable. Instead, use the tools described later in this chapter to modify your index. The file is also overwritten if you change behavior of managed properties, full-text indexes, or rank profiles.

Whether you use the SharePoint GUI, the cmdlets, or custom code to modify the index schema, the Microsoft.SharePoint.Search.Extended.Administration.Schema namespace is what is used behind the scenes. Using the classes in this namespace modifies and deploys the index schema configuration file mentioned previously.

Figure 6-1 shows the classes available to you via the SchemaContext class and how they relate to one another.

SchemaContext class hierarchy.

Figure 6-1. SchemaContext class hierarchy.

Crawled and Managed Properties

As described in Chapter 2, FS4SP has two types of index properties: crawled and managed. Everything you crawl enters the system as crawled properties—either because these properties existed as-is in the particular content source in structured data (for example, database columns, Microsoft Word document titles, or SharePoint columns) or because they were extracted from the document’s unstructured data during indexing (for example, webpage headers).

The default setting for most crawled properties is for its contents to be included in the search index without the need for you to take any action in order to search on the data from crawled properties. If you want to create a refiner on it, display it in a particular manner for your search results, sort on it, or use it in a search scope, you have to promote it to a managed property.

More Info

The category in which a crawled property belongs determines whether a crawled property is made searchable by default. You can read more about how to change this setting at http://technet.microsoft.com/en-us/library/ff191246.aspx.

If you have a crawled property that you want to omit from your search results, you have to change the default settings so that it will not be included. This can be useful for custom SharePoint columns or crawled properties from third-party IFilters that you don’t want in your search results.

Crawled properties are grouped in crawled property categories (metadata categories). For example, SharePoint columns go into the SharePoint category, metatags from webpages go into the Web Category, and properties of Word documents go into the Microsoft Office category.

Note

A good practice is to create separate categories for crawled properties that you create yourself in order to ease property management. This category separation is similar to grouping site columns in SharePoint.

Content that ends up in a managed property is usable when searching. You can define how queries interact with that data. For example, you can define whether lemmatization should be active, whether wildcard search patterns are allowed, and whether it should be possible to sort a result set on a particular property. All such attributes of a managed property are listed in Table 6-3.

Note

The property for turning lemmatization on and off is called stemming because the API is shared with SharePoint search.

Note

As you will see in the following sections, a managed property is represented internally as a regular object. Therefore, these properties are actual object properties that you get and set in Windows PowerShell and code just as you would for any other class instantiation.

Table 6-3. Attributes of a managed property

Attribute

Description

Value

DecimalPlaces

Gets or sets the number of decimal places. Only applicable for decimal-type managed properties.

3 (default)

Minimum: –28

Maximum: 28

DeleteDisallowed

Gets a Boolean value that indicates whether the managed property can be deleted. Only applicable for default, internal properties.

True

False (default)

Description

Gets or sets a text description for a managed property.

<optional>

IsMapped

Gets or sets a Boolean value that indicates whether the managed property is mapped to support Alternate Access Mapping.

True

False (default)

MappingDisallowed

Gets a Boolean value that indicates whether crawled properties can be mapped to the managed property.

True

False (default)

MaxIndexSize

Gets or sets the maximum number of kilobytes indexed for a managed property. Only applicable for managed properties of type text.

1,024

Maximum: 2,097,151 (2 GB)

MaxResultSize

Gets or sets the maximum number of kilobytes that are used for the result of a managed property—that is, how much content can be retrieved from the index for this managed property. This is applicable only for managed properties of type text.

64

Maximum: 2,097,151 (2 GB)

MergeCrawledProperties

Gets or sets a Boolean value that indicates whether to include the contents of all crawled properties mapped to a managed property. If this setting is disabled, the value of the first nonempty crawled property is used as the contents of the managed property. This has to be set to true to support multi-value data being assigned to it.

True

False (default)

Name

Gets the name of a managed property. Note that it is not possible to change the name of a managed property without deleting and recreating it.

<required>

Queryable

Gets or sets a Boolean value that indicates whether a managed property can be used in query operators and filter terms.

True (default)

False

RefinementEnabled

Gets or sets a Boolean value that indicates whether to enable a refiner for a managed property.

True

False (default)

SortableType

Gets or sets the sortable type for a managed property whether or not sorting is enabled.

LatentSortable is used to prepare a property for possible sorting in the future. Changing from LatentSortable to SortableEnabled does not require reindexing.

SortableDisabled (default)

SortableEnabled

LatentSortable

StemmingEnabled

Gets or sets a Boolean value that indicates whether a managed property is stemmed/lemmatized.

True

False (default)

SubstringEnabled

Gets or sets a Boolean value to indicate whether to enable substring matching for the managed property.

True

False (default)

SummaryType

Gets or sets the summary type for a managed property: static or dynamic, where the former tells FS4SP to calculate a dynamic teaser in which the search terms are highlighted.

Disabled

Static (default)

Dynamic

Type

Gets the data type; for example, Integer or Text. Note that it is not possible to change the type of a managed property without deleting and recreating it.

<required>

1 (Text)

2 (Integer)

3 (Boolean)

4 (Float)

5 (Decimal)

6 (Datetime)

Warning

Enabling substring matching on a managed property is mainly for supporting Asian languages. The index size greatly increases and search precision is reduced. But there are other uses for it, as you can see in the e-commerce sample in Chapter 10. You can read more about substring matching and Asian languages at http://technet.microsoft.com/en-us/library/gg130819.aspx.

In order to search and retrieve results from FS4SP, you need mappings from crawled properties to managed properties. You can, however, just start a crawl of a SharePoint site, a website, or even a file server, and expect to be able to query the index right away. This is because FS4SP comes with a large set of preconfigured crawled and managed properties, and mappings between them, perfectly suitable for most web content and documents. But as soon as you want to change the behavior of a certain property or you want to crawl nonstandard content sources, you very likely will have to tailor both mappings and the configuration of the managed properties.

Both crawled and managed properties have to be created. The FS4SP indexing pipeline contains a crawled property discovery processor called PropertiesReporter. This processor looks for structured metadata in the content and creates the corresponding crawled properties. There is also a companion processor called PropertiesMapper that makes sure that the mappings you defined are reflected in the internal structures of the index.

Note

If you change a mapping from a crawled to a managed property, you need to recrawl all affected documents for the change to take effect. This is because the PropertiesMapper processor has to resynchronize your new configuration into the index.

Because you typically do not have to create crawled properties yourself, but instead rely on the indexing pipeline to discover and extract them automatically, this chapter focuses on how to create and configure managed properties. When creating deployment scripts, a good recommendation is to create custom crawled and managed properties as part of the script, not relying on crawling to detect and create them. This saves you crawling the content twice only for crawled property discovery, which may take a considerable amount of time for large data volumes.

SharePoint

Working with managed properties via SharePoint Central Administration is a quick way to create, edit, or delete crawled and managed properties. The interface is very similar to that of SharePoint Search.

Create a managed property

  1. In Central Administration, click Manage Service Applications, and then click your FAST Query SSA.

  2. Under Administration, click FAST Search Administration.

  3. Under Property Management, click Managed Properties. You should now see a list of all existing managed properties, as shown in Figure 6-2. For each property, the type, the property’s options, and any existing mappings from crawled properties are listed.

    All existing managed properties, as shown on the FAST Query SSA.

    Figure 6-2. All existing managed properties, as shown on the FAST Query SSA.

  4. Click Add Managed Property, and then fill out the details as needed.

  5. At the very least, give the new property a unique name. A good practice is to prefix it with something unique in order to distinguish it from the other managed properties because there is no other way to group a set of managed properties. This makes future management easier.

    Note

    Historically, using lowercase names in FAST has been a good rule of thumb to make sure you do not encounter weird issues. This holds true for FS4SP as well; some cases have been reported on Microsoft forums, where using mixed casing has caused unforeseen trouble.

  6. Map one or more existing crawled properties to your new managed property.

  7. Indicate whether it should be possible to sort on the new managed property, target a fielded query against it, or refine on it.

  8. Decide whether you want to put the property into the default full-text index—that is, whether the content of the property should be searchable as-is. Note that if you omit mapping the property to a full-text index and choose not to check the Query Property, the new property will not be searchable in any way, nor can it be used as a refiner. However, it can still be used for presentation and sorting.

  9. Click OK.

Your new managed property should now be available in the list shown in Figure 6-2. If you configured mappings from crawled properties, you will have to recrawl any existing content associated with the crawled properties to make the changes go into effect.

Important

When mapping more than one crawled property to a managed property, you have to pay attention to the setting Include Values From A Single Crawled Property Based On The Order Specified, shown in Figure 6-3.

If this option is selected, only the first crawled property to be present in a particular item will be mapped to the managed property according to the order the crawled property mappings are listed.

Mapping crawled properties to a managed property.

Figure 6-3. Mapping crawled properties to a managed property.

Map a crawled property to a managed property

Mappings from crawled properties to a managed property can be added from both “sides” of the mapping. When you create a managed property as previously detailed, you have the option of specifying mappings right away. Also, by clicking an existing managed property in the list shown in Figure 6-2, you can add new mappings after the managed property is created. Both of these methods of creating mappings can be said to be through the perspective of the managed property. It is also possible to add a mapping to a crawled property from the perspective of a crawled property—that is, from the other way around.

There are no differences in creating the mapping from the crawled property or from the managed property perspective. For completeness, the following procedure explains how to do it from the former (because the latter was covered indirectly in the previous section):

  1. In Central Administration, click Manage Service Applications, and then click your FAST Query SSA.

  2. Under Administration, click FAST Search Administration.

  3. Under Property Management, click Crawled Property Categories. You should now see a list of all existing crawled property categories, shown in Figure 6-4. Because the number of crawled properties can be huge, FS4SP sorts the crawled properties into groups, typically according to content source.

    Tip

    You can create your own crawled properties group with the cmdlet New-FASTSearchMetadataCategory.

  4. Click any of the groups in which you want to modify a crawled property. In this example, click the SharePoint group.

  5. Click the crawled property that you want to modify; alternatively, you can search for it using the Search box at the top. In this example, click the crawled ows_Company property.

  6. On the Edit Crawled Property page, click the Add Mapping button. This opens a modal dialog box, shown in Figure 6-5.

    All existing crawled property categories.

    Figure 6-4. All existing crawled property categories.

    Select managed properties to which a crawled property should map.

    Figure 6-5. Select managed properties to which a crawled property should map.

  7. Pick one or many managed properties to map the crawled property against.

  8. Click OK.

Remember that you have to recrawl your content source to pick up the changes.

Windows PowerShell

The possibilities for working with properties in Windows PowerShell are greater than through the SharePoint GUI but less intuitive. This section contains a brief example of how to inspect and make changes to an existing managed property.

Inspect and modify managed properties

  1. Open an FS4SP shell.

  2. Run Get-FASTSearchMetadataManagedProperty to list each managed property installed in your solution. Run Get-FASTSearchMetadataManagedProperty | Measure-Object to find out how many properties there are.

  3. Run Get-FASTSearchMetadataManagedProperty -Name “Keywords” to inspect each property of the managed Keywords property. Your output should look similar to the following.

    PS C:FASTSearchin> Get-FASTSearchMetadataManagedProperty -Name "Keywords"
    
    Name                   : Keywords
    Description            : Keywords for this document
    Type                   : Text
    Queryable              : True
    StemmingEnabled        : True
    RefinementEnabled      : False
    MergeCrawledProperties : False
    SubstringEnabled       : False
    DeleteDisallowed       : False
    MappingDisallowed      : False
    MaxIndexSize           : 1024
    MaxResultSize          : 64
    DecimalPlaces          : 3
    SortableType           : SortableDisabled
    SummaryType            : Disabled
  4. Compare your output to the listing of properties in Table 6-3. From here, you can tell right away that the Keywords property is used to hold regular text (Type), that it is possible to query using the “keyword: query” syntax (Queryable), and that it is neither used for deep refinement (RefinementEnabled) nor sorting (SortableType). You do not, however, know whether it is included as-is in a free text search because you cannot tell from this output alone whether the property is used in a full-text index. See the following section, Full-Text Indexes and Rank Profiles, for more information about this.

  5. Changing any of the internal properties of a managed property is straightforward and can be done using two methods:

    • The simplest method is to use the Set-FASTSearchMetadataManagedProperty cmdlet. For example, let’s say you need to allocate more internal index space for keywords than the default of 1,024 KB. This is easily achieved using the following.

      Set-FASTSearchMetadataManagedProperty -Name "Keywords" -MaxIndexSize 2048
    • Your other option is to change the properties on a managed property object: Store the managed property in an intermediate variable, make a change to an internal property, and issue the property’s Update() method to update the index schema. Perusing the same example, use the following code.

      $keywords = Get-FASTSearchMetadataManagedProperty -Name "Keywords"
      $keywords.MaxIndexSize = 2048
      $keywords.Update()

Note

Changes to many of the internal properties of a managed property require that you recrawl your content so that internal index structures reflect your changes; changing the MaxIndexSize property is an example of this.

Create a managed property

  1. Open an FS4SP shell.

  2. Use the New-FASTSearchMetadataManagedProperty cmdlet to create a managed property. This cmdlet has two required parameters: -Name and -Type. The former is simply the desired name of the new managed property. The latter indicates its data type, represented as an integer. Table 6-4 lists all available data types and which integer to use to reference it. For example, to create a managed property called Salary that uses the data type Float, run the following command.

    New-FASTSearchMetadataManagedProperty -Name "Salary" -Type 4 –Description "A descriptive
    text"

Note

Make it a habit to always use the -Description parameter and give your new managed property a brief explanation. You will thank yourself later.

Table 6-4. Data types for managed properties

Integer

Type

Description

1

Text

UTF-8 encoded text

2

Integer

Signed 64-bit integer

3

Boolean

True or False

4

Float

Double-precision 64-bit floating point

5

Decimal

Integer with up to 28 decimals

6

DateTime

Time stamp in the ISO 8601 format

Map a crawled property to a managed property

  1. Open an FS4SP shell.

  2. Use the New-FASTSearchMetadataCrawledPropertyMapping cmdlet to register the mapping. Unfortunately, you cannot reference the managed property and the crawled property by name. Instead, you first retrieve their object references.

    $mp = Get-FASTSearchMetadataManagedProperty -Name "<ManagedPropertyName>"
    $cp = Get-FASTSearchMetadataCrawledProperty -Name "<CrawledPropertyName>"
    New-FASTSearchMetadataCrawledPropertyMapping -ManagedProperty $mp -CrawledProperty $cp

    Note

    Multiple crawled properties can be mapped to the same managed property. But pay attention; content from the crawled properties are either overwritten or suffixed in the managed property, depending on the value of the managed property’s internal property MergeCrawledProperties. Also remember that you need to recrawl content before the mapping is effective in the index.

List crawled property categories

  1. Open an FS4SP shell.

  2. Use the Get- FASTSearchMetadataCategory cmdlet to list all available property categories.

  3. Use Get- FASTSearchMetadataCategory “<category name>”, where <category name> is the name of the category to get a reference to only one category.

Create a crawled property category

When creating custom crawled properties, you may find it useful to store the properties in a separate category for maintenance purposes. The category is identified by a name and a property set in the form of a GUID.

  1. Open an FS4SP shell.

  2. Use the New-FASTSearchMetadataCategory cmdlet to create a crawled property category. Replace <String> with the name you want to give your category and <Guid> with a GUID of your making. The following sample creates a category named FS4SP Book with a random GUID. Be sure to print and make a note of the GUID after creation.

    $guid = [guid]::NewGuid()
    New-FASTSearchMetadataCategory -Name "FS4SP Book" -Propset $guid

Configure a category for crawled property discovery and searching

Crawled properties are automatically extracted from crawled content and grouped by category based on the property set of each crawled property. Each category can be configured individually to discover new crawled properties, or not.

  1. Open an FS4SP shell.

  2. Run the following command to turn off automatic discovery of new crawled properties for the category and to make the crawled properties added to the category searchable by default.

    $category = Get- FASTSearchMetadataCategory "FS4SP book"
    $category.MapToContents = 1
    $category.DiscoverNewProperties = 0
    $category.Update()

.NET

Working with crawled and managed properties via .NET code is very similar to using Windows PowerShell; the only difference is that you need to get a reference to the Schema object and property collections before you can start making changes.

Create a managed property

  1. Add a reference to the FS4SP administration main assembly by running the following.

    <FASTSearchFolder>inMicrosoft.SharePoint.Search.Extended.Administration.dll
  2. Add the corresponding namespaces.

    using Microsoft.SharePoint.Search.Extended.Administration;
    using Microsoft.SharePoint.Search.Extended.Administration.Schema;
  3. Initialize the connection to FS4SP and acquire an object reference to the index schema.

    SchemaContext schemaContext = new SchemaContext();
    Schema indexSchema = schemaContext.Schema;
  4. Add a new managed property using the following code.

    indexSchema.AllManagedProperties.Create("MyMP", "A descriptive text", ManagedType.Text);

    The AllManagedProperties property returns a special type of collection that lists all managed properties and exposes the Create method that adds new managed properties. The enum ManagedType exposes data type values that correspond to those listed in Table 6-4.

    Note

    There are two overloaded Create methods; the one not used in this example allows you to directly set several of the internal properties listed in Table 6-3. For more information about these two methods, go to http://msdn.microsoft.com/en-us/library/ee568851.aspx.

  5. After running the code, run Get-FASTSearchMetadataManagedProperty -Name “MyMP” in an FS4SP shell to verify that the managed property was in fact created and deployed.

    Note

    It is also possible to manually configure a connection to FS4SP and acquire the index schema through a proxy. However, SchemaContext uses the default endpoint name and configuration file (<FASTSearchFolder>etcAdmin.config) and provides easy access to the index schema as long as you execute your application locally on an FS4SP server. For more information about the SchemaContext class, go to http://msdn.microsoft.com/en-us/library/ee563682.aspx.

Map a crawled property to a managed property

  1. To map a crawled property to a managed property, you first need to obtain the index schema. Perform steps 1–3 from the previous example, “Create a managed property.” This leaves you with the indexSchema variable.

  2. In this example, you map the crawled property ows_Name into the managed property Author. These are default properties, and unless you manually removed them, this step should work fine.

  3. Just like you did when using the Windows PowerShell approach, in order to configure the mapping, you need to get objects for both the managed and the crawled properties. Let’s start with the easiest, the managed property.

    var mp = indexSchema.AllManagedProperties["Author"];
  4. As you saw in the section on crawled properties, you can use several methods for obtaining an object reference to a crawled property. In this example, you use the QueryCrawledProperties method, which lets you query for a crawled property name.

    Note that this method returns an IEnumerable<CrawledProperty> because several crawled properties might share the same name. In this example, you are giving yourself the liberty of assuming that there is only one property called ows_Name, which is the case in a default FS4SP installation. Be sure to put proper safeguards in place in your production environment to avoid null-pointer exceptions.

    var cp = indexSchema.QueryCrawledProperties("ows_Name", 0, 1).First();

    The second and third parameters are a query offset and a limit on how many matching crawled properties should be returned. In this example, you want to search the whole set (starting from offset 0), and only care for one specific property (stop after 1 match) using the First() method provided by Microsoft Language Integrated Query (LINQ) in the .NET Framework.

  5. Next, get a list of all existing mappings from the managed property, add the crawled property to that list, and write the list back to the managed property. Use the following code.

    var mappings = mp.GetCrawledPropertyMappings();
    mappings.Add(cp);
    mp.SetCrawledPropertyMappings(mappings);
  6. After running the code, use the following two lines of Windows PowerShell script, and verify that the crawled property was indeed mapped to the managed property.

    $mp = Get-FASTSearchMetadataManagedProperty -Name "Author"
    Get-FASTSearchMetadataCrawledPropertyMapping -ManagedProperty $mp

Full-Text Indexes and Rank Profiles

As previously described in Chapter 2, a full-text index contains a group of managed properties. This makes it possible for search queries to span multiple properties at the same time. Examples of managed properties in the default full-text index are title, body, and URL of an item.

Each managed property in the full-text index is given an importance level from 0 through 7. These levels give input to how FS4SP calculates dynamic rank. On top of this, a rank profile adds the final touches of rank calculation. Full-text indexes and rank profiles are central concepts in FS4SP and are the functionality used behind the scenes when users are doing a normal, “nonfielded” free-text search. When you sort your search results based on relevance, the rank profile is what applies the settings that determine the rank score for each item.

Note

Changing a managed property’s importance level is an easy way to change user-perceived relevance, but it can also affect index performance, query latency, and disk space requirements. A good guideline to follow is to keep properties that have potentially large amounts of data at one of the lower levels. The top-most levels should be reserved for small and important properties, such as titles.

Each rank profile is associated with at least one full-text index; a one-to-one mapping between a rank profile and a full-text index is the most common scenario, but you can assign multiple full-text indexes to a rank profile as well.

Every FS4SP configuration has at least one full-text index and one rank profile. This is often enough, but if your installation will be used to host completely separate types of data for completely separate purposes, it might be a good idea to set up multiple full-text indexes with separate rank profiles. This lets you tune relevance and index features in each index without worrying about full-text indexes and rank profiles interfering with each other. The recommendation by Microsoft is to have not more than 10 full-text indexes because adding more can have an adverse effect on disk usage and system resources.

More Info

For more information about the index schema and its features, go to http://technet.microsoft.com/en-us/library/gg982954.aspx.

The default full-text index is called content, and the default rank profile is called default. Inspect their properties by running the Get-FASTSearchMetadataFullTextIndex and Get-FASTSearchMetadataRankProfile cmdlets in an FS4SP shell.

PS C:FASTSearchin> Get-FASTSearchMetadataFullTextIndex
Name             : content
Description      : Default FullText Index
StemmingEnabled  : True
isDefault        : True
DeleteDisallowed : False

PS C:FASTSearchin> Get-FASTSearchMetadataRankProfile
Name                              : default
isDefault                         : True
RankModelName                     : default
StopWordThreshold                 : 2000000
PositionStopWordThreshold         : 20000000
QualityWeight                     : 50
AuthorityWeight                   : 80
QueryAuthorityWeight              : 50
FreshnessWeight                   : 100
FreshnessResolution               : Day
FreshnessManagedPropertyReference : Write

PS C:FASTSearchin> $rp = Get-FASTSearchMetadataRankProfile
PS C:FASTSearchin> $rp.GetFullTextIndexRanks()
FullTextIndexReference : content
ProximityWeight        : 140
ContextWeight          : 50

PS C:FASTSearchin> $rp.GetManagedPropertyBoosts()
ManagedPropertyReference : format
BoostValue               : unknown format,-4000,xml document,-4000,microsoft excel,-4000

In this code, you see listed six properties of the rank profile that relate to different weights. The weight numbers are not percentages but are relative weights. Freshness has the highest score in the default rank profile and impacts ranking the most, pushing newly changed content high up on the result list. Table 6-5 explains in more detail the different rank components at play within the rank profile.

Important

The value of two rank components with the same weight is not necessarily the same. Changing a weight from 50 to 100 on one component could impact the rank score more than changing a weight from 50 to 100 on another component.

When changing the values of the different weights, you need to use trial and error when you execute sample searches against your data to see how different values change the ranking of your search results. Another, possibly simpler, option to tuning the ranking is to dynamically change the search queries in FAST Query Language (FQL) with the xrank operator. This is explained in detail in Chapter 8.

Table 6-5. Rank components in the rank profile

Rank factor

Description

Rank type

Quality

Quality rank points are derived from the following managed properties:

  • Urldepthrank. Rank points given to boost shorter URLs

  • Docrank. Rank points given based on the number of and relative importance of links pointing to an item

  • Siterank. Rank points given based on the number of and relative importance of links pointing to the items on a site

  • Hwboost. FS4SP placeholder for generic usage of static/quality rank points

You can also add any managed property of type integer to the list of static/quality rank components.

Static

Freshness

Rank points based on the age (last modified) of the item compared to the time of the search. The source for the last modified time is the managed property named Write. The resolutions used (second/minute/hour/day/year) are important for the ranking; a lower resolution results in smaller time differences that affect the ranking.

Dynamic

Context

Rank points given based on where in the item the search words hit. Context boost is assigned as an overall weight and as a weight for an individual managed property. The different managed properties such as title and body are mapped into different importance levels. This makes it possible to give more rank points when the search word hits in a title instead of in the body text of the item.

Dynamic

Proximity

Rank points given depending on the distance between the search words and where these words are located in the search item. If two search terms appear close together in the same managed property within the full-text index, the item will get more rank points.

Dynamic

Managed property boost

Rank points given based on a specific value of a managed property. For example, if you want to give additional rank points to items of a specific type, such as Word documents, you would give items that have the value docx assigned in the fileextension managed property additional rank points.

Dynamic

Authority

Rank points given based on when a search word retrieves hits in the link text (anchor text). This rank boost has two components:

  • Partial match. When, for example, the link text is Microsoft Word and the search is Microsoft

  • Complete match. Additional score if there is an exact match between the search word and the link text

Dynamic

Query authority

Rank points given based on clicked search results (click-through). In the search front end, all of a user’s searches and the items that the user clicks that are associated with those searches are stored and processed. For example, if a user searched for vacation and clicked the vacation request template in the search result (for example, http://myserver/template/vacation.aspx), the URL is associated with the search term and receives additional rank points when any new search with the same search word is performed.

Processing of the stored queries is run on a daily basis. The last 30 days of clicks are kept for processing, so queries older than that no longer have an effect on the ranking.

This rank score also has two components:

  • Partial match. When, for example, the initial search words that resulted in a click to this item were Microsoft Word, and the search word now is Microsoft

  • Complete match. Additional score if there is an exact match between the search word and link text

Dynamic

Any rank profile can be used to sort the search result. Sorting on rank profiles is available both via the SharePoint Search Center and via code.

The full-text index has seven levels of importance, 7 being the highest. You can list the managed properties mapped to each level by running the GetMappingsForLevel method of the full-text index object. The following example lists the managed properties mapped to level 7.

PS C:FASTSearchin> $fti = Get-FASTSearchMetadataFullTextIndex
PS C:FASTSearchin> $fti.GetMappingsForLevel(7)

Name                   : Title
Description            : The title of the document
Type                   : Text
Queryable              : True
StemmingEnabled        : True
RefinementEnabled      : False
MergeCrawledProperties : False
SubstringEnabled       : False
DeleteDisallowed       : True
MappingDisallowed      : False
MaxIndexSize           : 1024
MaxResultSize          : 64
DecimalPlaces          : 3
SortableType           : SortableDisabled
SummaryType            : Dynamic

Name                   : DocSubject
Description            :
Type                   : Text
Queryable              : True
StemmingEnabled        : True
RefinementEnabled      : False
MergeCrawledProperties : False
SubstringEnabled       : False
DeleteDisallowed       : False
MappingDisallowed      : False
MaxIndexSize           : 1024
MaxResultSize          : 64
DecimalPlaces          : 3
SortableType           : SortableDisabled
SummaryType            : Static

You can also change the internal weights of each importance level by using the following code in an FS4SP shell.

PS C:FASTSearchin> $rankprofile = Get-FASTSearchMetadataRankProfile default
PS C:FASTSearchin> $content = $rankprofile.GetFullTextIndexRanks()|where-Object -filterscript
{$_.FullTextIndexReference.Name -eq "content"}
PS C:FASTSearchin> $content.GetImportanceLevelWeight(1)
30
PS C:FASTSearchin> $content.GetImportanceLevelWeight(2)
10
PS C:FASTSearchin> $content.GetImportanceLevelWeight(3)
20
PS C:FASTSearchin> $content.GetImportanceLevelWeight(4)
30
PS C:FASTSearchin> $content.GetImportanceLevelWeight(5)
40
PS C:FASTSearchin> $content.GetImportanceLevelWeight(6)
50
PS C:FASTSearchin> $content.GetImportanceLevelWeight(7)
60

Important

If you examine the importance level weights from the previous output, you notice that level 1 has the same weight as level 4. This is a bug that has yet to be fixed as of the December 2011 cumulative update for FS4SP. You can reset the levels to match their importance by using the following code in an FS4SP shell.

PS C:FASTSearchin> $rankprofile = Get-FASTSearchMetadataRankProfile default
PS C:FASTSearchin> $content = $rankprofile.GetFullTextIndexRanks()|where-Object
-filterscript {$_.FullTextIndexReference.Name -eq "content"}
PS C:FASTSearchin> $content.SetImportanceLevelWeight(1,10)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(2,20)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(3,30)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(4,40)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(5,50)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(6,60)
PS C:FASTSearchin> $content.SetImportanceLevelWeight(7,70)

If you add more full-text indexes and rank profiles, pay attention to the isDefault property, which tells you which full-text indexes and rank profiles are used unless a query is explicitly targeting a specific index.

More Info

For details about all the properties of the full-text index and rank profile, see the TechNet documentation for Set-FASTSearchMetadataRankProfile at http://technet.microsoft.com/en-us/library/ff393755.aspx and for Set-FASTSearchMetadataFullTextIndex at http://technet.microsoft.com/en-us/library/ff393749.aspx.

SharePoint

Through the SharePoint GUI, the possibilities to tune the full-text index and rank profile parameters are limited. As you will see, the possibilities through Windows PowerShell and code are greater. However, for each managed property, you can assign a full-text index mapping—that is, modify the level of importance used in the rank profile through the GUI. For many FS4SP configurations, this is often enough.

Modify a managed property’s full-text index mapping

  1. In Central Administration, point to Manage Service Applications, and then click your FAST Query SSA.

  2. Under Administration, click FAST Search Administration.

  3. Under Property Management, click Managed Properties. You should now see a list of all existing managed properties, as shown in Figure 6-2 earlier.

  4. Click a managed property, for example, body. This takes you to the Edit Managed Property page.

  5. At the very bottom of the page, you can change which importance level, or “priority,” should be associated with the managed property by using a drop-down menu. In the same place, you can inspect the default full-text index; see which other managed properties belong to the index and what important levels they have been assigned. Clicking the View Mappings link, directly under the drop-down menu, brings up a modal dialog box with this information, as shown in Figure 6-6.

The modal dialog box showing the default full-text index and which managed properties are part of it.

Figure 6-6. The modal dialog box showing the default full-text index and which managed properties are part of it.

Windows PowerShell

As you’ve seen, when you use SharePoint Central Administration, your options are limited to mapping managed properties to the default full-text index and assigning importance levels. Using Windows PowerShell, you can work with any full-text index or rank profile and have full control of your rank tuning.

Create a full-text index with an associated rank profile

  1. Open an FS4SP shell.

  2. Create a full-text index and rank profile, and then save the object references.

    $fti = New-FASTSearchMetadataFullTextIndex -Name "myfti" -Description "A short
    description"
    $rp = New-FASTSearchMetadataRankProfile -Name "myrp"

    The previous command creates the rank profile with default values. Using the -Template parameter with New-FASTSearchMetadataRankProfile, you can use another existing rank profile to override the defaults. New-FASTSearchMetadataFullTextIndex does not support using a template, but you can easily change its default values after creation by modifying the properties of the $fti object.

    Important

    Use lowercase names when creating full-text indexes and rank profiles to avoid unexpected errors.

  3. Extract the existing rank components from the rank profile, and then add the rank components from the full-text index by using the following code.

    $rankComponents = $rp.GetFullTextIndexRanks()
    $rankComponents.Create($fti)

    At this point, the new full-text index and rank profile is available and ready for use. However, the full-text index contains no managed properties, and the rank components are left at default values.

  4. To start using the new full-text index right away, mark it as default.

    $fti.MakeDefault()

    Note

    You can still use a rank profile for sorting even when the rank profile or the full-text index it is attached to is not set as default.

  5. To verify that the procedure worked as expected, either retrieve the list of full-text indexes by using the Get-FASTSearchMetadataFullTextIndex cmdlet and look for the isDefault property, or go to the Edit Managed Property page in Central Administration and click View Mappings, as shown in Figure 6-6.

Modify the list of full-text index rank components for a rank profile

  1. Locate the rank profile you want to modify, and then extract its rank components.

    $rp = Get-FASTSearchMetadataRankProfile -Name "MyRP"
    $rankComponents = $rp.GetFullTextIndexRanks()

    Important

    Because each rank profile can be used by many full-text indexes, you have to look up the elements in $rankComponents that are associated with your particular full-text index. In other words, modifying the rank components can affect more than one full-text index. Be careful.

  2. In this example, you want to increase the relevance boost of important managed properties, which you achieve by doubling the rank importance of the highest importance level (7). Unfortunately, there is no easy way to reference rank components belonging to a certain full-text index, so you have to resort to looping through them until you find the one you are looking for.

    foreach ($ftiRankComponent in $rankComponents)
    {
       if($ftiRankComponent.FullTextIndexReference.Name.Equals("MyFTI"))
       {
          var newFtiRankComponent = 2 * $ftiRankComponent.GetImportanceLevelWeight(7);
          $ftiRankComponent.SetImportanceLevelWeight(7, newFtiRankComponent);
       }
    }

    The changes to importance level weights do not take effect until the next recrawl. This is because the importance levels are part of static rank, which is evaluated at index time and not at query time.

.NET

If you compare the code used in the .NET samples, you see that the code is almost identical to that of Windows PowerShell. Using .NET for full-text indexes and rank profiles provides the same capabilities as Windows PowerShell.

Create a full-text index with an associated rank profile

  1. The first step in working with full-text indexes in code is to obtain the index schema. Perform steps 1–3 from the .NET procedure “Create a managed property” in the Crawled and Managed Properties section earlier in this chapter. This leaves you with the indexSchema variable.

  2. When you use the schema’s property AllFullTextIndecies, creating a new full-text index is straightforward and similar to creating a managed property.

    var fti = indexSchema.AllFullTextIndecies.Create("MyFTI", "A descriptive text");

    This creates a full-text index that has default values and is tied against the default rank profile.

  3. To verify that the procedure worked as expected, run the Get-FASTSearchMetadataFullText-Index cmdlet and make sure the new full-text index is listed.

  4. Because the full-text index uses the default rank profile, if you also want to associate it with a brand new rank profile, add the following lines of code.

    var rp = indexSchema.AllRankProfiles.Create("newrp");
    var rankComponents = rp.GetFullTextIndexRanks();
    rankComponents.Create(fti);

    Just as in the previous Windows PowerShell example, this creates a rank profile and associates the rank components with the full-text index. Note that the Create method on AllRankProfiles accepts a second parameter that specifies an existing rank profile as a template.

  5. To start using the new full-text index right away, mark it as default by using the following code.

    fti.MakeDefault();
  6. To verify that the procedure worked as expected, either retrieve the list of full-text indexes by using the Get-FASTSearchMetadataFullTextIndex cmdlet and look for the isDefault property, or go to the Edit Managed Property page in Central Administration and click View Mappings, as shown in Figure 6-6 earlier.

Modify the list of full-text index rank components for a rank profile

  1. The first step in working with full-text indexes in code is to get the index schema. Perform steps 1–3 from the .NET procedure “Create a managed property” in the Crawled and Managed Properties section earlier in this chapter. This leaves you with the indexSchema variable.

  2. Locate the rank profile you want to modify, and then extract its rank components by using the following code.

    var rp = indexSchema.AllRankProfiles["MyRP"];
  3. In the same manner as in the previous Windows PowerShell example, you now have to isolate the rank components that are associated with the targeted full-text index. Using LINQ, this is simple.

    var rankComponents = rp.GetFullTextIndexRanks()
                           .Where(rc => rc.FullTextIndexReference.Name.Equals("MyFTI"));
  4. Now modify each rank component the way you like; in this example, duplicate the scenario from the previous Windows PowerShell version.

    foreach(var rc in rankComponents) {
        var oldWeight = rc.GetImportanceLevelWeight(FullTextIndexImportanceLevel.
    ImportanceLevel7);
        rc.SetImportanceLevelWeight(FullTextIndexImportanceLevel.ImportanceLevel7, 2 *
    oldWeight);
    }

Note

You always have to run the Update method after editing rank components.

Managed Property Boosts

You can associate one or more managed property boosts with a rank profile. A property boost is a rank component that enables you to boost items based on a word match within a given managed property. Managed property boosts are part of the dynamic rank for a results rank score. The value is applied using the xrank operator during search.

Note

Managed property boosts are global to the rank profile they are added to and will be applied to all search queries.

You can list the managed property boost of the default rank profile by using the Get-FASTSearchMetadataRankProfile cmdlet in an FS4SP shell.

PS C:FASTSearchin> $rp = Get-FASTSearchMetadataRankProfile
PS C:FASTSearchin> $rp.GetManagedPropertyBoosts()
ManagedPropertyReference : format
BoostValue               : unknown format,-4000,xml document,-4000,microsoft excel,-4000

ManagedPropertyReference : fileextension
BoostValue               : csv,-4000,txt,-4000,msg,-4000,oft,-4000,zip,-4000,vsd,-4000,rtf,-4000

ManagedPropertyReference : IsEmptyList
BoostValue               : true,-4000

ManagedPropertyReference : IsListItem
BoostValue               : true,-4000

Any searchable managed property that has a matching value can be used as input for additional rank points. The boost can be both positive and negative values, either pushing items up or down the result list. With the default rank profile, four property boosts are already in place, as listed in Table 6-6. All of them apply 4,000 negative rank points to push content that is considered noise down the result list.

Table 6-6. Property boost from the default rank profile

Managed property

Matching value

Boost applied

Format

unknown format

xml document

microsoft excel

–4,000

Fileextension

csv

txt

msg

oft

zip

vsd

rtf

–4,000

IsEmptyList

True

–4,000

IsListItem

True

–4,000

Windows PowerShell

For the samples in this section, you work with a boost rule that promotes all items of format set to Web Page in the default rank profile. This has the effect of ranking these documents higher than, for example, wiki pages.

Create a managed property boost

  1. Open an FS4SP shell.

  2. Using the following code, obtain a reference to the default rank profile (which also happens to be named default).

    $RankProfile = Get-FASTSearchMetadataRankProfile -Name "default"
  3. Obtain a reference to the managed property format.

    $Property = Get-FASTSearchMetadataManagedProperty -Name "format"
  4. Create the managed property boost for the value Document and set the weight.

    $RankProfile.CreateManagedPropertyBoostComponent($Property, "Web Page, 5000")

    The property boost should take effect without doing a recrawl, but the boost might take some time to kick in because of caching.

Change a managed property boost

  1. Open an FS4SP shell.

  2. Obtain a reference to the default rank profile.

    $RankProfile = Get-FASTSearchMetadataRankProfile -Name "default"
  3. Obtain a reference to the managed property you want to update.

    $Boost = $RankProfile.GetManagedPropertyBoosts()
              | where-object { $_.ManagedPropertyReference.Name -eq "format" –and
                               $_.BoostValue -eq "Web Page, 5000"}
  4. Change the value to promote Word documents instead of webpages.

    $Boost.BoostValue = "Microsoft Word, 5000"
  5. Update the property boost.

    $Boost.Update()

Delete a managed property boost

  1. Open an FS4SP shell.

  2. Obtain a reference to the default rank profile.

    $RankProfile = Get-FASTSearchMetadataRankProfile -Name "default"
  3. Obtain a reference to the managed property you want to delete.

    $Boost = $RankProfile.GetManagedPropertyBoosts()
              | where-object { $_.ManagedPropertyReference.Name -eq "format" –and
                               $_.BoostValue -eq "Web Page, 5000"}
  4. Delete the managed property boost.

    $Boost.Delete()

.NET

For the samples in this section, you work with a boost rule that promotes all items of format set to Web Page in the default rank profile. This has the effect of ranking these documents higher than, for example, wiki pages.

Create a managed property boost

  1. The first step in working with full-text indexes in code is to get the index schema. Perform steps 1–3 from the .NET procedure “Create a managed property” in the Crawled and Managed Properties section earlier in this chapter. This leaves you with the indexSchema variable.

  2. Using the schema’s property AllRankProfiles, you obtain a reference to the default rank profile.

    RankProfile rankProfile = indexSchema.AllRankProfiles["default"];
  3. Using the schema’s property AllManagedProperties, you obtain a reference to the managed property named format.

    ManagedProperty managedProperty = indexSchema.AllManagedProperties["format"];
  4. Obtain the existing managed property boost collection and create a boost for your managed property:

    var managedPropertyBoosts = rankProfile.GetManagedPropertyBoosts();
    managedPropertyBoosts.Create(managedProperty, "Web Page, 5000");

Change a managed property boost

The following code sample retrieves the managed property boost created in “Create a managed property boost” and changes the value to Microsoft Word, 2000.

SchemaContext schemaContext = new SchemaContext();
Schema indexSchema = schemaContext.Schema;

// Fetch the rank profile named 'default', which is the default rank profile.
RankProfile rankProfile = indexSchema.AllRankProfiles["default"];

// Fetch the existing managed property boost for format
ManagedPropertyBoostComponent boostComponent = rankProfile.GetManagedPropertyBoosts()
      .Where(boost => boost.ManagedPropertyReference.Name.ToLower() == "format"
                      && boost.BoostValue == "Web Page, 5000")
      .First();

boostComponent.BoostValue = "Microsoft Word, 2000";
boostComponent.Update();

Delete a managed property boost

The following code sample deletes the managed property boost created in “Create a managed property boost.”

SchemaContext schemaContext = new SchemaContext();
Schema indexSchema = schemaContext.Schema;

// Fetch the rank profile named 'default' which is the default rank profile.
RankProfile rankProfile = indexSchema.AllRankProfiles["default"];

// Fetch the existing managed property boost for format
ManagedPropertyBoostComponent boostComponent = rankProfile.GetManagedPropertyBoosts()
      .Where(boost => boost.ManagedPropertyReference.Name.ToLower() == "format"
                      && boost.BoostValue == "Web Page, 5000")
      .First();

// Delete the property boost
boostComponent.Delete();

Static Rank Components

Static rank points, also known as quality rank points, are added to items at index time. Static rank boosting is efficient from a search performance point of view because this boosting does not add any complexity to the search evaluation. Static rank points assigned to an indexed item are independent of the search words used. Any managed property of type integer can be used as part of the static rank. Table 6-5 earlier in this chapter lists the default managed properties used as static rank components.

The weight assigned to a managed property in the static rank component is a percentage that is used to multiply the number from the managed property. A weight of 100 means the value from the managed property is added to the score, a weight of 200 doubles the value, and a weight of 50 adds half the value. So when assigning the weight multiplier, take into account what number range your managed property will span.

Windows PowerShell

For the sample in this section, you add one-tenth of the items byte size as a static rank component.

More Info

See the e-commerce sample in Chapter 10 for another example of adding static rank components.

Add a static rank component to the default rank profile

  1. Open an FS4SP shell.

  2. Obtain a reference to the default rank profile (which also happens to be named default).

    $RankProfile = Get-FASTSearchMetadataRankProfile -Name "default"
  3. Obtain a reference to the existing static rank components.

    $QualityComponents = $RankProfile.GetQualityComponents()
  4. Obtain a reference to the managed property size.

    $Property = Get-FASTSearchMetadataManagedProperty -Name "size"
  5. Add the managed property to the static rank.

    $QualityComponents.Create($Property, 10)

Collection Management

A collection contains items from one or more content sources, for example, SharePoint sites or web crawls. For crawls based on the FAST Content SSA, the default collection is named sp. Because the FAST Search specific connectors do not depend on the FAST Content SSA, these connectors can feed data to any collection.

Note

A collection is nothing but a logical grouping of indexed items. The index is not physically split to accommodate for different collections. Each item contains an internal property called meta.collection. This property tells FS4SP which collection the item belongs to.

You usually do not need to have more than one content collection; the default collection sp is enough. In previous FAST technology, having several collections was standard procedure. One could argue that the notion of a collection in FS4SP is redundant and has instead been replaced by the concept of content sources; but in some cases, it is convenient to have more than one content collection, for example when using any of the FAST Search specific connectors and you want to search on or clear all data from one particular FAST Search specific connector. You can read more about the FAST Search specific connectors in Chapter 7.

Collections are only manageable through the FS4SP shell and the .NET administration API.

Windows PowerShell

Managing collections via Windows PowerShell is done with the following cmdlets:

  • Clear-FASTSearchContentCollection

  • Get-FASTSearchContentCollection

  • New-FASTSearchContentCollection

  • Remove-FASTSearchContentCollection

To view all currently available collections, run Get-FASTSearchContentCollection. Running this also tells you how many items are associated with the collection, which pipeline the collection uses, and when items were last run through the pipeline associated with the collection.

PS C:FASTSearchin> Get-FASTSearchContentCollection
Name          : sp
Created       :
Cleared       : 2011-03-14T19:27:32.7753906+01:00
LastInput     : 7/12/2011 5:14:23 PM
DocumentCount : 135
Description   : Default collection for SharePoint content
Pipeline      : Office14 (webcluster)

To create or remove collections, run either New-FASTSearchContentCollection –Name [name] or Remove-FASTSearchContentCollection –Name [name]. Note that the latter also removes all items associated with the collection.

To clear out all items associated with a specific collection without removing the collection itself, run Clear-FASTSearchContentCollection –Name [name]. When clearing the content collection, you do not clear the items that are in the corresponding SharePoint crawler database. In order to synchronize the crawler database with clearing a content collection, you have to do an index reset on the FAST Content SSA.

.NET

Managing collections via the .NET API is done using the ContentContext class.

Create a content collection

  1. Add a reference to the FS4SP administration main assembly.

    <FASTSearchFolder>inMicrosoft.SharePoint.Search.Extended.Administration.dll
  2. Add the corresponding namespaces.

    using System.Linq;
    using Microsoft.SharePoint.Search.Extended.Administration;
  3. Initialize the connection to FS4SP and acquire an object reference to the ContentContext object.

    ContentContext contentContext = new ContentContext();
  4. Create a collection. The first parameter is the collection name, the second is the collection description, and the third is the name of the pipeline to use.

    contentContext.Collections.AddCollection("notes", "Lotus notes", "Office14
    (webcluster)");

Important

The AddCollection method in the ContentCollectionCollection class has an overloaded method that takes two parameters, the name and the description of the collection. However, there is a bug in this method because it tries to create a collection with a pipeline named Office14, but the default pipeline to use is named Office14 (webcluster). Using this method generates an AdminException exception.

As of the December 2011 cumulative update, SharePoint 2010 has a bug that points the WCF proxy to a service named ContentCollection.svc on the FS4SP administration server, but the correct name is ContentCollectionService.svc. In order to use the ContentContext within SharePoint, you have to copy <FASTSearchFolder>componentsadmin-servicescontentcollectionservice.svc to a file named <FASTSearchFolder>componentsadmin-servicescontentcollection.svc on the FS4SP administration server.

Delete a content collection

  1. Follow steps 1–3 of the previous procedure, “Create a content collection.”

  2. Get a reference to the collection you want to remove.

    ContentCollection collection = contentContext.Collections.Where(coll => coll.Name ==
    "notes").First();
  3. Remove the content collection.

    contentContext.Collections.Remove(collection);

    Remember that if your collection contains items indexed via the FAST Content SSA, you have to do an index reset on the FAST Content SSA in order to clear the crawler database and keep the FAST Content SSA in sync with the actual index.

Scope Management

A scope, or search scope, is a filter that users can target queries against. Scopes are a query-time feature and will not affect the underlying index in any way.

More Info

You can read more about scopes in the Search Scopes section in Chapter 2, and read more about FQL in Chapter 8.

Although the SharePoint GUI has support for creating simple scopes, the possibilities are not complete. The recommended method is using Windows PowerShell, which allows you to define arbitrary scope expressions by using FQL. Of course, this is also possible through code. Scopes can be created either globally at the search service application level or locally at the site level.

To inspect which scopes exist, either go to your FAST Query SSA and click Scopes under Queries And Results in the navigation pane, as shown in Figure 6-7, or use the following cmdlet Get-SPEnterpriseSearchQueryScope. Note that this is a SharePoint Enterprise Search cmdlet and is available only through the SharePoint Management Shell.

PS C:FASTSearchin> Get-SPEnterpriseSearchQueryScope -SearchApplication "FAST Query SSA"
Name                      ID   Count  LastCompilationTime      CompilationState
----                      --   -----  -------------------      ----------------
People                    0    0      3/14/2011 6:16:52 PM     Compiled
All Sites                 1    0      3/14/2011 6:16:52 PM     Compiled
Global Query Exclusion    2    0      1/1/0001 12:00:00 AM     Empty
Rank Demoted Sites        3    0      1/1/0001 12:00:00 AM     Empty

The last two scopes in this code block are internal to the SharePoint search and are not used with FS4SP.

When creating search scopes, you can make them either global—meaning they are accessible for the entire site collection—or you can make them available only for a specific site collection.

SharePoint

Creating scopes via SharePoint Central Administration is similar to that of SharePoint search and allows you to create scopes to limit your search results based on URL matching and managed property values.

Create a global scope

  1. In Central Administration, point to Manage Service Applications, and then click your FAST Query SSA.

  2. Under Queries And Results, click Scopes. This takes you to the View Scopes page shown in Figure 6-7, where all scopes available to your users are listed.

    The View Scopes page.

    Figure 6-7. The View Scopes page.

  3. Click New Scope.

  4. Enter a title and description of the new scope.

  5. In the Target Results Page section, specify whether you want search results from the scope to be presented in the standard Search Results Page (Searchresults.aspx) or in a custom webpage.

  6. Click OK to create the scope and return to the View Scopes page. Although the scope is now active, it is not yet of any use because no scope rules are attached to it.

  7. On the View Scopes page, click the Add Rules link to the right of the scope name.

  8. Specify a rule type. You have the following options:

    • Select the Web Address option if you want the scope to include or exclude content based on a URL—that is, a website, files from a share, and so on.

    • Select the Property Query option if you want the scope to filter results by using a managed property.

      Important

      The managed properties listed in the Add Property Restrictions drop-down are the properties that exist in the index schema of Search Server—that is, the drop-down does not reflect the FS4SP index schema. This is because scopes are functionality from the built-in SharePoint search. If you want to use a managed property from FS4SP in a scope defined using Central Administration, you must also create an identical managed property in the SharePoint search schema. All of the FS4SP default managed properties already have equivalents in Search Server. For a step-by-step guide about creating scopes via Central Administration, go to http://technet.microsoft.com/en-us/library/ff453895.aspx.

    • Select the All Content option if you want more complex rules scenarios where, for example, you combine a complex rule with an exclusion rule. First include everything, and then exclude something. The All Content rule is used by the built-in search of SharePoint; it has no impact on FS4SP and can be omitted.

  9. In the Behavior section, select the Include, the Require, or the Exclude option to specify how this scope rule will affect the overall scope.

  10. Click OK to save the new scope rule.

Note

If you use more than one scope in a query against FS4SP, AND is used; OR is not supported.

Windows PowerShell

Using Windows PowerShell for scope management is, in the authors’ opinion, the best way to manage scopes in FS4SP unless you only want to limit search results on the default managed properties. With Windows PowerShell, you can take advantage of FQL and create complex rule sets on any queryable managed property.

Create a global scope

  1. Search scopes are functionality from SharePoint Enterprise Search; as such, the cmdlets for working with scopes are not available through the FS4SP shell. Instead, use the SharePoint Management Shell.

  2. Scopes are created using the New-SPEnterpriseSearchQueryScope cmdlet. Because this cmdlet is not FS4SP functionality by itself, you have to specify which Search Service Application (SSA) should be used by using the -SearchApplication parameter.

  3. In this example, we want to create a scope on a content collection. This scope is particularly useful because there is no other built-in method of querying documents only from a certain collection. We circumvent this limitation by targeting the scope against the internal property meta.collection.

    Note

    You typically use multiple content collections with the FAST Search specific connectors, and you cannot filter these using the managed property ContentSource.

    New-SPEnterpriseSearchQueryScope -Name "CollScope" -Description "Scope on collection2"
    -SearchApplication "FAST Query SSA" -DisplayInAdminUI 1 -ExtendedSearchFilter "meta.
    collection:collection2"
  4. Give the operation a little while to go into effect because it will be picked up by a SharePoint timer job. When it is fully deployed, you should be able to search for term scope:CollScope in your Search Center. This search makes sure results containing term also belong to our new search scope.

More Info

Even though scopes are not compiled with the end results like they are in the built-in SharePoint search, compilation of the scopes is what makes them available during searching. You can manually start a compilation by opening a SharePoint Management Shell and executing the following commands, where <FASTQuerySSA> is the name of your FAST Query SSA.

$ssa = Get-SPEnterpriseSearchServiceApplication "<FAST Query SSA>"
$ssa.StartScopesCompilation()

Modify an existing scope

  1. Obtain an object reference to a scope, for example, CollScope created in the previous example.

    $scope = Get-SPEnterpriseSearchQueryScope -Identity "CollScope" -SearchApplication "FAST
    Query SSA"

    Note

    The name of the scope is specified using the -Identity parameter and not with the -Name, as was the case with the New-SPEnterpriseSearchQueryScope cmdlet.

  2. The FQL filter you created in the previous example was specified using the -ExtendedSearchFilter parameter. From the scope object, you can modify the filter by using the Filter property. To make changes go into effect, the Update method must be called after the scope has been modified.

    $scope.Filter = "meta.collection:collection3"
    $scope.Update()

Delete an existing scope

  • Get an object reference to a scope—for example, CollScope—and pipe it through the Remove-SPEnterpriseSearchQueryScope cmdlet.

    Get-SPEnterpriseSearchQueryScope -Identity "CollScope" -SearchApplication "FAST Query
    SSA" | Remove-SPEnterpriseSearchQueryScope
  • Alternatively, you can get a reference to the scope and call the Delete method on the object.

    $scope = Get-SPEnterpriseSearchQueryScope -Identity "CollScope" -SearchApplication "FAST
    Query SSA"
    $scope.Delete()

.NET

Using .NET for scope management offers the same flexibility as using Windows PowerShell. You work with scope management via the Scopes object.

Create a global scope

  1. Add a reference to the SharePoint search administration main assembly.

    %CommonProgramFiles%Microsoft SharedWeb Server Extensions14ISAPI
    Microsoft.Office.Server.Search.dll
  2. Add the corresponding namespace.

    using Microsoft.Office.Server.Search.Administration;
  3. While this code runs on SharePoint, you need to first get a reference to the SearchServiceApplication used. You do this via the SearchServiceApplicationProxy object from the current SharePoint context.

    var ssaProxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.
    GetProxy(SPServiceContext.Current);
    var searchApplictionInfo = ssaProxy.GetSearchServiceApplicationInfo();
    var searchApplication = SearchService.Service.SearchApplications.GetValue<SearchServiceAp
    plication>(searchApplictionInfo.SearchServiceApplicationId);
  4. Next, you need to get a reference to the Scopes object, which is instantiated with the search application object.

    Scopes scopes = new Scopes(searchApplication);
  5. Create a global scope that has the same parameters as in the previous Windows PowerShell sample. To create a site-level scope, add the site URL as the third parameter.

    scopes.AllScopes.Create("CollScope", "Scope on collecion2", null, true, null,
    ScopeCompilationType.AlwaysCompile, "meta.collection:collection2");
  6. Finally, to force the compilation and use of the scope right away, call StartCompilation on the object.

    scopes.StartCompilation();

Modify an existing scope

  1. Perform steps 1–4 in the previous procedure, “Create a scope,” to get a reference to your scopes object.

  2. Get a reference to the scope you created named CollScope.

    var scope = scopes.GetSharedScope("CollScope");
  3. Modify the filter property, update the scope, and start a compilation to effectuate the changes right away.

    scope.Filter = "meta.collection:collection3";
    scope.Update();
    scopes.StartCompilation();

Delete an existing scope

  1. Carry out steps 1–4 in the “Create a scope” procedure to get a reference to your scopes object.

  2. Get a reference to the scope you created named CollScope.

    var scope = scopes.GetSharedScope("CollScope");
  3. Call the Delete method on the scope object.

    scope.Delete();

Property Extraction Management

Property extraction can be used to improve the search experience by identifying known properties in your items during indexing. The properties are searched for within all the item text, not just in metadata; you can see this as a way to find structured data in unstructured text. You can read more about property extraction and how to create custom extractors in Chapter 7.

Note

Property extraction was known as entity extraction in previous FAST versions. Therefore, some of the documentation you find on TechNet and in APIs refer to entity extraction. For all intents and purposes, entities and properties are the same.

Built-in Property Extraction

FS4SP comes with three default property extractors:

  • Company names

  • Location names

  • Person names (not enabled by default)

Each of these lists can be modified by adding entries to include lists to make sure the list detects properties not automatically detected out of the box; the same goes for exclude lists to ignore entities that it wrongly detects.

The procedure for adding inclusion and exclusion entries is the same for companies, locations, and person names; you use the location list for the samples.

More Info

Custom property extraction is covered in Chapter 7.

SharePoint

Using SharePoint Central Administration for management of the property extraction lists is useful when you want to list the terms added or when you want to add or remove a few of them. Bulk operations are not possible via Central Administration.

Add a term to a property extraction list

  1. In Central Administration, point to Manage Service Applications, and then click your FAST Query SSA.

  2. Click the FAST Search Administration link in the left column, shown in Figure 6-8.

    The link to the FAST Search Administration page in the FAST Query SSA.

    Figure 6-8. The link to the FAST Search Administration page in the FAST Query SSA.

  3. Under Property Extraction, click Manage Property Extraction.

  4. Point to Locations, and click the down arrow. Then select Edit Include List, shown in Figure 6-9. Choose Edit Exclude List to add terms that you want to omit from the property extractor.

  5. Click Add Item.

  6. Enter the term to include a location name extraction, for example, North Pole, as shown in Figure 6-10.

Property extractor administration.

Figure 6-9. Property extractor administration.

New term to be added to a list.

Figure 6-10. New term to be added to a list.

Remove a term from a property extraction list

  1. Follow steps 1–3 from the previous “Add a term to a property extraction list” procedure.

  2. Point to the term you want to remove, and then choose Delete Item, as shown in Figure 6-11.

Removing a property extraction term.

Figure 6-11. Removing a property extraction term.

Windows PowerShell

Using Windows PowerShell is an easy way of bulk-importing terms to the property extraction lists. Windows PowerShell provides functions for reading text files and executing commands that use each line in the file as an input. The following samples can be easily incorporated in such loops.

Add a term to a property extraction list

  1. Open an FS4SP shell.

  2. No Windows PowerShell cmdlets are included with FS4SP to work with the property extractor lists, but you can use the .NET object in Windows PowerShell to accomplish your task. You can get a reference to the EntityExtractorContext object by using the following line of code.

    $entityExtractorContext = New-Object -TypeName Microsoft.SharePoint.Search.Extended.
    Administration.EntityExtractorContext
  3. Get a reference to the Locations list.

    $locationEntities = $entityExtractorContext.TermEntityExtractors | where { $_.Name -eq
    "locations" }
  4. Add a new term to the inclusion list.

    $locationEntities.Inclusions.Add("North Pole")

Remove a term from a property extraction list

  1. Follow steps 1–3 from the previous “Add a term to a property extraction list” procedure.

  2. Remove the term.

    $locationEntities.Inclusions.Remove("North Pole")

.NET

Using .NET, you can maintain your property extraction lists in SharePoint lists that are easily edited by using, for example, Microsoft Excel. Using event receivers on the SharePoint lists, you can automatically trigger the code in the following procedure to batch update the terms.

Add a term to a property extraction list

  1. Add a reference to the FS4SP administration main assembly.

    <FASTSearchFolder>inMicrosoft.SharePoint.Search.Extended.Administration.dll
  2. Add the corresponding namespaces.

    using System.Linq;
    using Microsoft.SharePoint.Search.Extended.Administration;
    using Microsoft.SharePoint.Search.Extended.Administration.Linguistics;
  3. Initialize the connection to FS4SP and acquire an object reference to the TermEntityExtractor for locations:

    EntityExtractorContext entityExtractorContext = new EntityExtractorContext();
    TermEntityExtractor locationEntitites = entityExtractorContext.TermEntityExtractors.
    Where(t => t.Name == "locations").First();
  4. Add a term to the inclusion list.

    locationEntitites.Inclusions.Add("North Pole");

Remove a term from a property extraction list

  1. Follow steps 1–3 in the previous “Add a term to a property extraction list” procedure.

  2. Remove the term from the inclusion list.

    locationEntitites.Inclusions.Remove("North Pole");

Keyword, Synonym, and Best Bet Management

Using keywords is a great way to enhance your search results. These terms are defined by either an FS4SP administrator or FS4SP keyword administrator on a per-site collection basis. If you have a Search Center on more than one site collection, you have to add the keywords to each site collection where you want them available.

Each keyword can be associated with the following:

  • Synonyms

  • Best bets

  • Visual best bets

  • Document promotions

  • Document demotions

When a search query is executed via the SharePoint site search box or the Search Center site, the search query is matched against the list of keywords or synonyms, and recommended results from the best bets or visual best bets are displayed above your search results. The same applies to document promotions and document demotions that are matched, but here the actual search result is moved to either the top or bottom of the result list.

Best bets, visual best bets, document promotions, and document demotions can all have a start date and an end date and can be associated with user contexts. A user context can be any combination of properties from a user’s SharePoint User Profile page. (See the section titled User Context Management later in this chapter.) By default, you can base your context on the Office Location and Ask Me About properties.

Important

Keyword terms in search queries must exactly match the defined keyword or one of its synonyms. Partial matches are not matched. If the keyword defined is car and the user searches for red car, the keyword will not match because it is not an exact match.

Only use synonyms to improve recall for small result sets. If you add synonyms for keywords that already have a large result set, the additional results will be added to the end of the result set and the query performance will be significantly reduced.

More Info

Read more about working with keywords via SharePoint Central Admin at http://office.microsoft.com/en-us/fast-search-server-help/manage-fast-search-keywords-HA010381994.aspx and via Windows PowerShell at http://technet.microsoft.com/en-us/library/ff453900.aspx.

Keywords

Keywords are the base feature for synonyms, best bets, visual best bets, document promotions, and document demotions. You first add a keyword, and then you attach features to it.

Tip

Best bets and visual best bets are particularly useful for campaigns and question/answer types of information. For example, if a user on an intranet site searches for fire extinguisher, it would be good to show where these are located in the building on an office map, and not necessarily show items containing the words. And if a user on a public-facing insurance company website searches for car insurance, you can show this month’s good insurance offer as a visual best bet above the other results.

Use visual best bets when you want more control over how you visualize the best bet because regular best bets are text only.

SharePoint

The following samples take you through the steps involved in working with keywords and keyword-related functionality via SharePoint Site Collection Administration.

Display the Manage Keywords page

  1. Log on to the home page of your top-level site as a user with site collection administration privileges. Make sure the user is a member of either the local group FASTSearchAdministrators or FASTSearchKeywordAdministrators on the FS4SP administration server.

  2. Go to Site Actions | Site Settings | Site Collection Administration.

  3. Click FAST Search Keywords, shown in Figure 6-12.

A link to FAST Search keywords from Site Collection Administration.

Figure 6-12. A link to FAST Search keywords from Site Collection Administration.

Add a keyword with synonyms

  1. Display the Manage Keywords page.

  2. Click Add Keyword, shown in Figure 6-13.

  3. Fill in the keyword information. The phrase you will match is fast search for sharepoint, and you will add two-way synonyms for fs4sp and enterprise search. This means that when a user searches for fast search for sharepoint, he will also search for fs4sp and enterprise search and vice versa. If you don’t want searches to match the synonym, use a one-way synonym instead. Several synonym terms can be added and separated with a semicolon, as shown in Figure 6-14.

  4. Click OK.

Add a new keyword.

Figure 6-13. Add a new keyword.

Add a keyword with synonyms.

Figure 6-14. Add a keyword with synonyms.

Note

The actual FQL query being executed when a user searches for fast search for sharepoint is shown in the following code. Pay attention to the filter() operator around the synonyms that turn off any stemming (or actually, lemmatization) for the synonym terms.

or(
    string(
        "fast search for sharepoint",
         annotation_class="user",
         mode="simpleall"
    ),
     filter(
        or(
            ""enterprise search"",
            ""FS4SP""
        )
    )
)

Add a best bet

  1. Display the Manage Keywords page.

  2. Point to your keyword, click the down arrow, and choose Add Best Bet from the displayed menu, as shown in Figure 6-15.

  3. Fill in the Title, Description, and URL boxes for your best bet, as shown in Figure 6-16. This information will be shown above the other results on your search page in the Best Bets Web Part. You can also fill in a start date and an end date for when the best bet is to be shown, and associate one or more user contexts.

  4. Click OK.

Add best bets and document boosts to a keyword.

Figure 6-15. Add best bets and document boosts to a keyword.

Associate a best bet with a keyword.

Figure 6-16. Associate a best bet with a keyword.

Remove a best bet

  1. Display the Manage Keywords page.

  2. Point to the best bet count for your keyword, and then click the down arrow.

  3. Move your pointer over Delete Best Bets, and pick the best bet you want to delete, as shown in Figure 6-17.

Remove a best bet association from a keyword.

Figure 6-17. Remove a best bet association from a keyword.

Add a visual best bet

  1. Display the Manage Keywords page.

  2. Move the mouse over your keyword, click the down arrow, and choose Add Visual Best Bet from the displayed menu, as shown in Figure 6-15.

  3. Fill in the Title and URL boxes for the visual best bet, as shown in Figure 6-18. You can also fill in a start date and an end date for when the visual best bet is to be shown, and associate one or more user contexts.

Associate a visual best bet with a keyword.

Figure 6-18. Associate a visual best bet with a keyword.

Note

The URL of a visual best bet can point to either an image or a webpage. The visual best bet is loaded into an iframe, so make sure the content fits inside the dimensions specified in the Visual Best Bet Web Part. For more information about iframes, go to http://en.wikipedia.org/wiki/Iframe#Frames.

Tip

If you are going to display a SharePoint page as a visual best bet, you can try to append IsDlg=1 at the end of the URL. This removes most of the default SharePoint chrome and is the same parameter used when SharePoint displays pages as dialog boxes internally.

Remove a visual best bet

  1. Display the Manage Keywords page.

  2. Point to the visual best bet count for your keyword, and then click the down arrow.

  3. Move your pointer over Delete Visual Best Bets, and then pick the visual best bet you want deleted, as shown previously in Figure 6-17.

Add a document promotion

  1. Display the Manage Keywords page.

  2. Point to your keyword, click the down arrow, and then choose Add Document Promotion from the displayed menu shown in Figure 6-15 earlier.

  3. Fill in the Title and URL boxes for your document promotion as shown in Figure 6-19. The promoted item will be moved to the top of a search query matching the associated keyword. You can also fill in a start date and an end date for when the document promotion should be active, and you can associate one or more user contexts.

Associate a document promotion to a keyword.

Figure 6-19. Associate a document promotion to a keyword.

Note

When you examine the FQL generated for a document boost, you see that the promoted item is given 1,000,000 extra rank points, effectively moving it to the top of the result list.

xrank(
    string(
        "fast search for sharepoint",
         annotation_class="user",
         mode="simpleall"
    ),
     meta.contentid:equals(
        string(
            "http://test//Documents/FS4SP-Sales.pptx",
             linguistics="off",
             wildcards="off"
        )
    ),
     boost=1000000
)

Remove a document promotion

  1. Display the Manage Keywords page.

  2. Point to the document promotion count for your keyword, and then click the down arrow.

  3. Point to Delete Document Promotion, and then pick the promotion you want to delete.

Add a document demotion

  1. Display the Manage Keywords page.

  2. Point to your keyword, click the down arrow, and then choose Add Document Demotion from the displayed menu shown earlier in Figure 6-15.

  3. Fill in the Title and URL boxes for your document demotion. The promoted item will be moved to the bottom of a search query matching the associated keyword. You can also fill in a start date and an end date for when the document demotion is to be active, and you can associate one or more user contexts.

Note

The generated FQL is similar to the one for document promotions, but the demoted item is given –1,000,000 rank points, moving it to the bottom of the result list.

Remove a document demotion

  1. Display the Manage Keywords page.

  2. Point to the document demotion count for your keyword, and then click the down arrow.

  3. Point to Delete Document Demotion, and then pick the promotion you want to delete.

Windows PowerShell

The following samples take you through the steps involved in working with keywords and keyword-related functionality via Windows PowerShell.

Add a keyword with synonyms

  1. Open an FS4SP shell.

  2. You need to get a reference to a search settings group. If you added a keyword for a site collection by using SharePoint Site Collection Administration, this group is already created for you. If not, you need to create it yourself. If you have only one site collection, you have one search settings group and can omit the Name parameter. You can also execute Get-FASTSearchSearchSettingsGroup by itself to list all groups already created. The name of the search settings group is the ID of the site collection it belongs to.

    $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
  3. Add the keyword, and get a reference to it.

    $keyword = $searchSettingGroup.Keywords.AddKeyword("fast search for sharepoint")
  4. Now you need to add the synonyms either by using one-way or two-way expansion:

    • Add the synonyms by using two-way expansion.

      $keyword.AddSynonym("fs4sp")
      $keyword.AddSynonym("enterprise search")
    • Add the synonyms by using one-way expansion.

      $keyword.AddSynonym("fs4sp", "OneWay")
      $keyword.AddSynonym("enterprise search", "OneWay")

More Info

The search settings group name is in the form of a GUID and is a reference to the site collection for which your keywords should be added. From a SharePoint Management Shell, execute the following command to get the correct GUID.

(Get-SPSite -Identity "http://test").ID

Then in an FS4SP shell, create the new search settings group by using the following command. Use the GUID from the previous command as the name parameter if it is not already created for you.

New-FASTSearchSearchSettingGroup –Name "<GUID>"

Add a best bet

  1. Open an FS4SP shell.

  2. Get a reference to the keyword on the site collection where you want to add the best bet.

    $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
    $keyword = $searchSettingGroup.Keywords.GetKeyword("fast search for sharepoint")
  3. Create a URI object that points to the location of the best bet, where <URL> is the URL, for example, http://www.contoso.com.

    $uri = New-Object -TypeName System.Uri -ArgumentList "<URL>"
  4. Add the best bet location to the keyword, where <BestBetName> is the title of the best bet and <HTMLTeaser> is the teaser linked to the best bet in HTML. The teaser is neither used nor displayed in the Best Bet Web Part.

    $keyword.AddBestBet("<BestBetName>", "<HTMLTeaser>", $uri)

Remove a best bet

  1. Follow steps 1–2 of the previous “Add a best bet” procedure.

  2. Remove the best bet.

    $keyword.RemoveBestBet("<BestBetName>")

Add a visual best bet

  1. Follow steps 1–3 of the “Add a best bet” procedure.

  2. Add the visual best bet link to the keyword, where <VisualBestBetName> is the title of the visual best bet and the URL points to the visual best bet content.

    $visualBestBet = $keyword.AddFeaturedContent("<VisualBestBetName>")
    $visualBestBet.Uri = $uri

Remove a visual best bet

  1. Follow steps 1–2 of the “Add a best bet” procedure.

  2. Remove the visual best bet.

    $keyword.RemoveFeaturedContent("<VisualBestBetName >")

Add a document promotion/demotion

  1. Follow steps 1–2 of the “Add a best bet” procedure.

  2. Add the document promotion, where <PromotionName> is the title of the document promotion, <DocumentId> is the URL of the item you want promoted, and <BoostValue> is the value you want to boost the item with. Negative values demote the item instead of promoting it. The value used via Central Administration is 1,000,000 to ensure the item is put at the top of the result list, but you can reduce the value to create a softer boost.

    $promotion = $keyword.AddPromotion("<PromotionName>")
    $promotion.BoostValue = "<BoostValue>"
    $promotion.PromotedItems.AddPromotedDocument("<DocumentId>")

Remove a document promotion/demotion

  1. Follow steps 1–2 of the “Add a best bet” procedure.

  2. Remove the document promotion, where <PromotionName> is the title of the document promotion and <DocumentId> is the URL of the item you promoted.

    $promotedItems = $keyword.Promotions["<PromotionName>"].PromotedItems
    foreach ($promotedDocument in @($promotedItems.GetPromotedDocumentEnumerator()))
    {
       if ($promotedDocument.DocumentId -eq "<DocumentId>")
       {$promotedItems.Remove($promotedDocument)}
    }

Create a global best bet/visual best bet

Using Windows PowerShell, you can create best bets or visual best bets that always appear for any query and do not match a specific keyword search term. Remember that global means within one site collection.

  1. Open an FS4SP shell.

  2. Get a reference to the search settings group on the site collection where you want to add the global best bet.

    $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
  3. Create a URI object that points to the location of the best bet, where <URL> is the URL, for example, http://www.contoso.com.

    $uri = New-Object -TypeName System.Uri -ArgumentList "<URL>"
  4. Add the global best bet or visual best bet.

    // Add a global best bet
    $searchSettingGroup.BestBetsWithoutKeyword.AddBestBet("<GlobalBestBetName>", $uri)
    
    // Add a global visual best bet
    $searchSettingGroup.FeaturedContentWithoutKeyword.AddFeaturedContent("<GlobalVisualBestB
    etName>", $uri)

Create a global document promotion/demotion

Using Windows PowerShell, you can create a document promotion or demotion that applies for any query and does not match a specific keyword search term.

  1. Follow steps 1–2 of the “Add a best bet” procedure.

  2. Add the document promotion, where <GlobalPromotionName> is the title of the document promotion, <DocumentId> is the URL of the document you want promoted, and <BoostValue> is the value you want to boost the document with. Negative values demote the document instead of promoting it.

    $globalPromotions = $searchSettingGroup.PromotionsWithoutKeyword
    $globalPromotion = $globalPromotions.AddPromotion("<GlobalPromotionName>")
    $globalPromotion.BoostValue = "<BoostValue>"
    $globalPromotion.PromotedItems.AddPromotedDocument("<DocumentId>")

.NET

Working with keywords in .NET code is achieved via the KeywordContext class. This class resides in the Microsoft.SharePoint.Search.Extended.Administration.Keywords namespace.

The following code sample walks you through the steps needed to work with keywords in .NET. The sample consists of a main function called KeywordWalkthrough, where all the keyword operations are shown; and a helper function called GetSearchSettingGroup, which retrieves the correct search settings group for the site collection you are working with. If the group does not exist, it will be created.

using System;
using System.IO;
using System.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Search.Extended.Administration;
using Microsoft.SharePoint.Search.Extended.Administration.Keywords;
using Microsoft.SharePoint.Search.Extended.Administration.ResourceStorage;
using Microsoft.SharePoint.Search.Extended.Administration.Schema;

public class FS4SPKeywordsSample
{
   private void KeywordWalkthrough()
   {
      using (SPSite siteCollection = new SPSite("http://test/"))
      {
        SearchSettingGroup searchSettingGroup = GetSearchSettingGroup(siteCollection);

        // Add keyword
        var keyword = searchSettingGroup.Keywords.AddKeyword("fast search for sharepoint");

        // Add synonym with two-way expansion
        keyword.AddSynonym("fs4sp", SynonymExpansionType.TwoWay);

        // Add synonym with one-way expansion
        keyword.AddSynonym("enterprise search", SynonymExpansionType.OneWay);

        // Remove a synonym
        keyword.RemoveSynonym("enterprise search");

        // Add a Best Bet to the keyword
        keyword.AddBestBet("Microsoft", new Uri("http://www.microsoft.com"));

        // Remove a Best Bet from the keyword
        keyword.RemoveBestBet("Microsoft");

        // Add a Visual Best Bet to the keyword with start date and end date
        var featuredContent = keyword.AddFeaturedContent("Microsoft Logo");
        featuredContent.Uri = new Uri("http://site/microsoft_logo.png");
        featuredContent.StartDate = DateTime.UtcNow;
        featuredContent.EndDate = DateTime.UtcNow.AddMonths(1);

        // Remove a Visual Best Bet from the keyword
        keyword.RemoveFeaturedContent("Microsoft Logo");

        // Add two document promotions to the keyword
        var promotion = keyword.AddPromotion("Top promotions");
        promotion.BoostValue = 1000000;
        promotion.PromotedItems.AddPromotedDocument("http://site/Docs/Mydoc.docx");
        promotion.PromotedItems.AddPromotedDocument("http://site/Docs/Myotherdoc.docx");

        // Remove a document promotion from the keyword
        var documentEnumerator = promotion.PromotedItems.GetPromotedDocumentEnumerator();
        string removeId = "http://site/Documents/Mydocument.docx";
        while (documentEnumerator.MoveNext())
        {
            if (documentEnumerator.Current.DocumentId != removeId) continue;
            promotion.PromotedItems.Remove(documentEnumerator.Current);
            break;
        }

        // Add a soft demotion of the home page to the keyword
        var demotion = keyword.AddPromotion("Soft demotion");
        demotion.BoostValue = -1000;
        demotion.PromotedItems.AddPromotedDocument("http://site/default.aspx");

        // Add a site promotion to the keyword
        var sitepromotion = keyword.AddPromotion("Site promotion");
        sitepromotion.BoostValue = 1000;
        Uri promoUri = new Uri("http://www.microsoft.com");
        sitepromotion.PromotedItems.AddPromotedLocation(promoUri);

        // Add a global site promotion
        var sitepromo = searchSettingGroup.PromotionsWithoutKeyword.AddPromotion("Site");
        sitepromo.BoostValue = 1000;
        sitepromo.PromotedItems.AddPromotedLocation(new Uri("http://www.microsoft.com"));

        // Remove a global site promotion URL
        var siteEnumerator = keywordsitepromotion.PromotedItems.GetPromotedLocationEnumerator();
        Uri removeLocation = new Uri("http://www.microsoft.com");
        while (siteEnumerator.MoveNext())
        {
            if (siteEnumerator.Current.Uri != removeLocation) continue;
            keywordsitepromotion.PromotedItems.Remove(siteEnumerator.Current);
            break;
        }

        // Remove a global site promotion
        searchSettingGroup.PromotionsWithoutKeyword.RemovePromotion("Site");

        // Remove the keyword
        searchSettingGroup.Keywords.RemoveKeyword("fast search for sharepoint");
      }
   }

   // Helper method to get the correct search setting group
   private SearchSettingGroup GetSearchSettingGroup(SPSite siteCollection)
   {
     KeywordContext keywordContext = new KeywordContext();
     SearchSettingGroupCollection ssg = keywordContext.SearchSettingGroups;
     SearchSettingGroup group = ssg
             .Where(searchSettingGroup => searchSettingGroup.Name.ToLower() ==
                                     siteCollection.ID.ToString().ToLower())
             .FirstOrDefault();
     // Create the group if it does not exist
     if( group == null)
     {
         group = ssg.AddSearchSettingGroup(siteCollection.ID.ToString());
     }
     return group;
   }
}

Site Promotions and Demotions

Items that belong to highly relevant sites can be given a soft site promotion that causes the items to appear somewhat higher on the result list. When the user types a query that matches an item within the promoted site, the item will appear higher up in the search result list than what the normal ranking would imply. Similarly, you can apply soft site demotions to items from sites that are less important.

SharePoint

The following samples take you through the steps involved in working with site promotions and demotions via SharePoint Site Collection Administration.

Add a site promotion

  1. Log on to the home page of your top-level site as a user with site collection administration privileges. Make sure the user is a member of either the local group FASTSearchAdministrators or FASTSearchKeywordAdministrators on the FS4SP administration server.

  2. Go to Site Actions | Site Settings | Site Collection Administration.

  3. Under Site Collection Administration, click FAST Search Site Promotion And Demotion.

  4. Click Add Site Promotion.

  5. Give the site promotion a title, and then click the Add button in the Promoted Sites category to add a new site to promote.

  6. Enter the URL of the site you want to promote, and then click Add. You can add several URLs by repeating this step. Example: http://www.contoso.com/.

Note

The URLs of the result items will match if they start with the URL entered in the site promotion and they are given a soft promotion of 1,000 rank points. If a user searches for microsoft and you have a site promotion for http://www.contoso.com, the final FQL that is executed will look like the following.

xrank(
    string(
        "microsoft", annotation_class="user", mode="simpleall"
    ),
    urls:starts-with(
        string(
            "http://www.contoso.com/",
             linguistics="off", wildcards="off", tokenization="generic"
        )
    ),
    boost=1000
)

Add a site demotion

  1. Log on to the home page of your top-level site as a user with site collection administration privileges.

  2. Navigate to Site Actions | Site Settings | Site Collection Administration.

  3. Under Site Collection Administration, click FAST Search Site Promotion And Demotion.

  4. Click Manage Site Demotion.

  5. Click Add Site Demotion.

  6. Give the site demotion a title, and then click the Add button in the Demoted Sites category to add a new site to demote.

  7. Enter the URL of the site you want to demote, and then click Add. You can add several URLs by repeating this step. Example: http://www.contoso.com/.

More Info

For more information about working with site promotion and demotion using SharePoint administration, go to http://office.microsoft.com/en-us/fast-search-server-help/promoting-or-demoting-sites-HA010381927.aspx.

Windows PowerShell

The following samples take you through the steps involved in working with site promotions and demotions via Windows PowerShell.

Add a site promotion to a keyword

  1. Open an FS4SP shell.

  2. Get a reference to the keyword on the site collection where you want to add the best bet.

    $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
    $keyword = $searchSettingGroup.Keywords.GetKeyword("fast search for sharepoint")
  3. Add the document promotion, where <PromotionName> is the title of the site promotion, <URL> is the URL of the site you want promoted, and <BoostValue> is the value you want to boost the site with. Negative values demote the site instead of promoting it.

    $promotion = $keyword.AddPromotion("<PromotionName>")
    $promotion.BoostValue = <BoostValue>
    $uri = New-Object -TypeName System.Uri -ArgumentList "<URL>"
    $promotion.PromotedItems.AddPromotedLocation($uri)

Add a global site promotion

Remember that global means within one site collection.

  1. Follow steps 1–2 of the previous “Add a site promotion to a keyword” procedure.

  2. Add the site promotion, where <GlobalPromotionName> is the title of the site promotion, <URL> is the URL of the site you want promoted, and <BoostValue> is the value you want to boost the site with. Negative values demote the site instead of promoting it.

    $globalPromotions = $searchSettingGroup.PromotionsWithoutKeyword
    $globalPromotion = $globalPromotions.AddPromotion("<GlobalPromotionName>")
    $globalPromotion.BoostValue = "<BoostValue>"
    $uri = New-Object -TypeName System.Uri -ArgumentList <URL>
    $globalPromotion.PromotedItems.AddPromotedLocation($uri)

More Info

For more information about working with site promotion and demotion using SharePoint administration, go to http://technet.microsoft.com/en-us/library/ff191225.aspx.

.NET

See the .NET sample in the Keywords section earlier in this chapter for information about how to add site promotions and demotions with code.

FQL-Based Promotions

Earlier in this chapter, you learned about promoting and demoting items and sites based on URLs. Another option, which is not available via the SharePoint administration page, is creating promotions based on FAST query language (FQL).

In its simplest form, FQL-based promotions can be used in a fashion similar to managed property boosts, by boosting items where a managed property has a specific value. The main difference with FQL-based promotions and managed property boosts is that a managed property boost is applied to all search queries run against the rank profile it is attached to, whereas a promotion is scoped to queries from one site collection. In addition, FQL-based promotions can be attached to a keyword and user contexts. All in all, FQL-based promotions are more flexible than managed property boosts.

Windows PowerShell

The following Windows PowerShell script achieves the same results as the sample for managed property boosts, where you wanted to promote all items that have format set to Web Page with 5,000 rank points. Run the Windows PowerShell script in an FS4SP shell.

$searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
$globalPromotions = $searchSettingGroup.PromotionsWithoutKeyword
$globalPromotion = $globalPromotions.AddPromotion("FQL Promo")
$globalPromotion.BoostValue = "5000"
$fql = 'format:"Web Page"'
$globalPromotion.PromotedItems.AddPromotedExpression($fql)

Taking this a bit further, you can create a global demotion that demotes all items that are larger than 3 MB and from a file server that has –4,000 rank points.

$searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
$globalPromotions = $searchSettingGroup.PromotionsWithoutKeyword
$globalPromotion = $globalPromotions.AddPromotion("FQL size and file")
$globalPromotion.BoostValue = "-4000"
$fql = 'and(size:range(int("3145728"),max,from="gt",to="le"),url:starts-with("file://"))'
$globalPromotion.PromotedItems.AddPromotedExpression($fql)

User Context Management

In the previous section, you learned about how you can add keywords with features such as synonyms, best bets, and document promotions. All of these features can be attached to one or more user contexts. As you learned earlier in the chapter, user contexts enable you to promote documents differently depending on the person doing the search. In addition, user contexts show different best bets above the search results. This is a good start to personalizing the search experience for your users. In order to create user contexts, you have to configure the User Profile Service Application.

After you create your user contexts, they are available for use with the FAST Search Keywords and FAST Search Site Promotion And Demotion links.

More Info

For detailed information about how to set up the User Profile Service Application in SharePoint, go to http://technet.microsoft.com/en-us/library/ee721049.aspx.

SharePoint

The following sample takes you through the steps involved in setting up a user context via SharePoint Site Collection Administration.

Create a user context

  1. Go to Site Actions | Site Settings | Site Collection Administration.

  2. Click FAST Search User Context, shown in Figure 6-20.

    Link to FAST Search User Context from Site Collection Administration.

    Figure 6-20. Link to FAST Search User Context from Site Collection Administration.

  3. Click Add User Context.

  4. Give the user context a name in the User Context Name box.

  5. Pick values for the Office Location box and/or values for the Ask Me About box, shown in Figure 6-21.

    Create a user context.

    Figure 6-21. Create a user context.

  6. Click OK.

Windows PowerShell

The following sample takes you through the steps involved in setting up a user context via Windows PowerShell.

More Info

For detailed tutorials about how to use Windows PowerShell with user contexts, go to http://technet.microsoft.com/en-us/library/ff191223.aspx.

Create a user context

  1. Open an FS4SP shell.

  2. Get a reference to the search settings group for your site collection, where <GUID> is the ID of your site collection. See the “Add a keyword with synonyms” procedure earlier in this chapter for information about how to obtain a reference to your site collection ID.

    $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name "<GUID>"
  3. Add a new search context, where <ContextName> is the name you give your user context.

    $context = $searchSettingGroup.Contexts.AddContext("<ContextName>")
  4. Add user profile properties to your newly created context. You build a context expression by using AND, OR, and NOT operators, as in the following example.

    $andExpression = $context.AddAndExpression()
    $orExpression = $andExpression.AddOrExpression()
    $orExpression.AddMatchExpression("<PropertyName0>","<PropertyValue0>")
    $orExpression.AddMatchExpression("<PropertyName1>","<PropertyValue1>")
    $notExpression = $andExpression.AddNotExpression()
    $notExpression.AddMatchExpression("<PropertyName2>","<PropertyValue2>")

    Where <PropertyName> items are names of user properties and <PropertyValue> items are the values you want to check against for the given property. The preceding sample yields the following expression after it is computed.

    (<PropertyName0>:<PropertyValue0> OR <PropertyName1>:<PropertyValue1>)
    AND
    (NOT (<PropertyName2>:<PropertyName2>))

Note

The Boolean operator object used when creating the user context is not to be confused with keyword syntax or FQL used during searching. This is a domain-specific syntax for user contexts.

Adding More Properties to User Contexts

As seen in the previous example, by default, you can choose from only two properties when creating a user context, namely Office Location and Ask Me About. Using other properties from a person’s profile page to create user contexts could also be useful.

Add a user profile property to be used in user contexts

  1. In Central Administration, point to Manage Service Applications, and then click User Profile Service Application.

  2. Under the People section, click Manage User Properties.

  3. Pick the property you would like to use in your user context (for example Department), and then click Edit.

  4. Record the name of the property shown in the Name box. It is important to use the internal name of the property and not the display name; these differ for some properties.

  5. Open a SharePoint Management Shell.

  6. Execute the following commands to retrieve the existing properties of SPS-Location and SPS-Responsibility, and then add Department to the list.

    $contextprops = Get-SPEnterpriseSearchExtendedQueryProperty –SearchApplication "FAST
    Query SSA" -Identity "FASTSearchContextProperties"
    
    $newprops = $contextprops.Value + ",Department"
    Set-SPEnterpriseSearchExtendedQueryProperty -SearchApplication "FAST Query SSA" -Identity
    "FASTSearchContextProperties" -Value $newprops
  7. The new field should appear after a short time, or you can force it by recycling the SharePoint web application pool.

  8. Follow the previous procedure, “Create a user context,” and you can now use your added property.

Conclusion

Out of the box, FS4SP has many features that you can take advantage of by simply using the administrative interfaces in SharePoint. This is a powerful offering because search administrators or power users can modify and tune the search solution without the involvement of technical personnel.

But, as you saw from the samples that use Windows PowerShell or .NET code, these two options give you even more flexibility and functionality. Windows PowerShell is also a good option for larger deployments because you can script everything when moving between environments. Or you can program the setup in .NET and run the code, for example, on feature activation in SharePoint. Both approaches make it easier to set up new servers and environments, and also to upgrade them, as you adapt your search solution.

Some of the changes you do to your full-text indexes and rank profiles can have a severe impact on your search solution and might require you to recrawl all the content, whereas others can be added and tested right away. Keywords and scopes are both easy to configure and have low system impact. Editing the managed properties and creating good user contexts require more understanding of your content, your users, and how FS4SP works internally in order to get it right.

By testing the different options available and understanding how they work, you will gain valuable insight into FS4SP and learn to create powerful search solutions. In the end, it is up to you to familiarize yourself with the differences between the tools and pick the one most suited for your particular need.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.236.62