KeywordContext Class

Entry point for the search keyword management functionality (e.g. search setting groups, best bets, synonyms, etc.).

Inheritance Hierarchy


Namespace:  Microsoft.SharePoint.Search.Extended.Administration
Assembly:  Microsoft.SharePoint.Search.Extended.Administration (in Microsoft.SharePoint.Search.Extended.Administration.dll)


<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
Public NotInheritable Class KeywordContext _
    Implements IDisposable
Dim instance As KeywordContext
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
public sealed class KeywordContext : IDisposable


The following C# example uses the class to create a keyword and associate it with a synonym, a best bet, etc.

             using System;
             using Microsoft.SharePoint.Search.Extended.Administration;
             namespace Example
                 class Program
                     static void Main(string[] args)
                         using (KeywordContext keywordContext = new KeywordContext())
                             // Get a search setting group by id.
                             var searchSettingGroup = keywordContext.SearchSettingGroups.GetSearchSettingGroup("Search setting group id");
                             // Create a keyword.
                             var keyword = searchSettingGroup.Keywords.AddKeyword("contoso");
                             // Create a synonym.
                             keyword.Synonyms.AddSynonym("contoso corporation");
                             // Create a best bet.
                             var bestbet = keyword.BestBet.AddBestBet("Contoso Home Page");
                             bestbet.Uri = new Uri("");
                             // Create a document promotion.
                             var promotion = keyword.Promotions.AddPromotion("Promotion for developers");
                             promotion.BoostValue = 1000000;
                             // Create a context that matches people that have a developer role.
                             var context = searchSettingGroup.Contexts.AddContext("Developer context");
                             context.ContextExpression.AddMatchExpression("role", "developer");
                             // Attach the context to the developer promotion.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


KeywordContext Members

Microsoft.SharePoint.Search.Extended.Administration Namespace