locked
Programmatic Search Settings Configuration RRS feed

  • Question

  • Hi,

     

    I could need some help with a SharePoint administration script/program I want to code. Can someone tell me how to set the following WebUI setting programmatically?

     

    Site Settings > Site Collection Administration > Search Settings > Search Center

     

    Any help or feedback is appreciated.

     

    Thanks,

     

    Frank

    Thursday, November 22, 2007 4:15 PM

Answers

  • See the following post: http://stsadm.blogspot.com/2007/10/set-search-center.html.

     

    This is basically what you do:

    string url = "your site collection url";


    using (SPSite site = new SPSite(url))
    using (SPWeb web = site.RootWeb)
    {
    string searchCenter = "your search center url";
    web.AllProperties["SRCH_ENH_FTR_URL"] = searchCenter;
    web.Update();
    }

     

    Sometime I've found that the SDK documentation is less than helpful and tend to resort to disassembling the web pages that you'd hit when doing this via the browser.

    Friday, November 23, 2007 12:32 AM

All replies

  • You could programatically administer sharepoint search. Things like content sources, content propogation

    search scopes, crawl rules and search keywords etc can be administered using API's

     

    This is clearly dealt in MOSS 2007 SDK. It can be downloaded from the following location

    http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&displaylang=en

     

    Please refer the section 'Programmatically Administering Search' section in the SDK for more details

     

     

     

     

     

    Thursday, November 22, 2007 4:27 PM
  • See the following post: http://stsadm.blogspot.com/2007/10/set-search-center.html.

     

    This is basically what you do:

    string url = "your site collection url";


    using (SPSite site = new SPSite(url))
    using (SPWeb web = site.RootWeb)
    {
    string searchCenter = "your search center url";
    web.AllProperties["SRCH_ENH_FTR_URL"] = searchCenter;
    web.Update();
    }

     

    Sometime I've found that the SDK documentation is less than helpful and tend to resort to disassembling the web pages that you'd hit when doing this via the browser.

    Friday, November 23, 2007 12:32 AM
  • Hi Gary,

     

    Thanks, that was exactly what I was looking for. BTW very nice blog - I'll keep an eye on you/your blog.

     

    Cheers,

    Frank

    Friday, November 23, 2007 10:48 AM