using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Query;
public DataSet getSearchResults(string strSqlString)
{
DataSet dsResults = null;
string strSiteUrl = ConfigurationManager.AppSettings["siteId"].ToString();
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(strSiteUrl))
{
FullTextSqlQuery query = new FullTextSqlQuery(site);
query.QueryText = strSqlString;
query.RowLimit = 30000;
query.ResultTypes = ResultType.RelevantResults;
ResultTableCollection coll = query.Execute();
if ((int)ResultType.RelevantResults != 0)
{
ResultTable tblResult = coll[ResultType.RelevantResults];
if (tblResult.TotalRows > 0)
{
DataTable dtResults = new DataTable("tblResults");
dsResults = new DataSet();
dsResults.Tables.Add(dtResults);
dsResults.Load(coll[ResultType.RelevantResults], LoadOption.OverwriteChanges, dtResults);
}
}
}
});
}
catch (Exception ex)
{
throw ex;
}
return dsResults;
}
No comments:
Post a Comment