I have created custom search scope in the FARM Level and I am able to see in my site collection search scope settings and I can enable to make custom search scope move it to default group through browser. Is there anyway I can achieve the same functionality using Custom coding in moss 2007 Object Model.
http://nickgrattan.files.wordpress.com/2007/08/shsc1.jpg?w=700
Any help would be appr开发者_运维问答eciated
Thanks
Deepu
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();
}
}
精彩评论