Programmatically starting and incremental crawl in Sharepoint SSP
Posted on 2/27/2009 2:02:47 AM
in #SharePoint
Hi,/o:p>/span>/p>
/o:p>/span>/p>
When working is Sharepoint we have to work with Sharepoint search. Search point search works with indexed data. The data is indexed with the help of the Sharepoint crawl. For crawling purpose, we normally make one full crawl and after that incremental crawl at different interval based on the requirement. /p>
/o:p>/span>/p>
But some times business might require that incremental crawl must be executed on update of some very important records. At this point we have two option one to schedule the incremental crawl to lowest possible time difference (like 2 minutes). But this can be very resource exhaustive for the server and can cause some performance issue on the server. /p>
/o:p>/span>/p>
Another possible solution can be that we start the incremental crawl by code itself. This crawl should be started by on the update of any important data as per the business requirement. /p>
/o:p>/span>/p>
I had a similar requirement where the business wanted to get the updated data in the search result in 1 minute for a particular list. For this I created a way which would make incremental crawl on call. Below is the code for the same./p>
/o:p>/span>/p>
string strURL = SPContext.Current.Site.Url;/p>
SearchContext context;/p>
/p>
using (SPSite site = new SPSite(strURL))/p>
{/p>
context = SearchContext.GetContext(site);/p>
}/p>
/p>
Microsoft.Office.Server.Search.Administration.Content sspContent = new Microsoft.Office.Server.Search.Administration.Content(context);/p>
/p>
//// fetch the name of the Content Source from the config file string strContentSource = ConfigurationManager.AppSettings["ContentSources"]; /p>
ContentSourceCollection sspContentSources = sspContent.ContentSources;/p>
ContentSource cs = sspContentSources[strContentSource];/p>
/p>
if (cs.CrawlStatus == CrawlStatus.Idle)/p>
{/p>
cs.StartIncrementalCrawl();/p>
}/p>
/p>
That’s all you need to do to start an incremental crawl in the Sharepoint SSP./o:p>/span>/p>
/o:p>/span>/p>
Regards/p>
Vikram/o:p>/span>/p>
|
Posted on 2/16/2009 1:31:00 PM
I executed the exe. But i guess it didn't my event handler. Can I have the code.
/p>
|
Posted on 10/5/2009 10:52:13 AM
Hi
Thanks a lot for the post. It was good. But, can you tell when did you call this code that programmatically monitors the incremental crawling.
/p>
|
Posted on 8/25/2010 2:29:09 AM
this solution does not seem to work in the web farm,where
we tried to call the above code from an event receiver..
/p>
any suggestion ...
/p>
thanks
/p>
|
Posted on 8/25/2010 3:23:08 AM
Hi,
How do you get this to work in a Farm environment. Two WFE's and one Index server.
/p>
We face an issue which throws an error
"The underlying connection was closed: An unexpected error occurred on a send."
"Job 'Distribution List Import Job' failed. It will be re-tried again in 60 second(s).
/p>
Reason: Failed to obtain crawl status.
/p>
Techinal Details:
Microsoft.Office.Server.UserProfiles.UserProfileException: Failed to obtain crawl status. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
"
/p>
|