我已经在FARM级别创建了自定义搜索范围,我可以在我的网站集中查看搜索范围设置,我可以启用自定义搜索范围,通过浏览器将其移动到默认组。无论如何,我可以使用moss 2007对象模型中的自定义编码实现相同的功能。
http://nickgrattan.files.wordpress.com/2007/08/shsc1.jpg?w=700
任何帮助将不胜感激
由于
迪普
答案 0 :(得分:0)
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Administration;
static void CreateScope()
{
SearchContext searchContext;
using (SPSite site = new SPSite("Your SiteCollection Site"))
{
searchContext = SearchContext.GetContext(site);
Scopes scopes = new Scopes(searchContext);
Scope newScope = scopes.AllScopes.Create("CustomScope", "Scope Description", new Uri(site.Url), true, "Your Custom Serach aspx Page", ScopeCompilationType.AlwaysCompile);
newScope.Rules.CreateUrlRule(ScopeRuleFilterBehavior.Include, UrlScopeRuleType.Folder, "Folder Name");
newScope.Update();
ScopeDisplayGroup group = scopes.GetDisplayGroup(new Uri(site.Url), "Search Dropdown");
group.Add(newScope);
group.Update();
}
}