{
SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue
SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue
KeywordQuery keywordQuery = new KeywordQuery(searchProxy);
string SearchScope = "PEOPLE";
keywordQuery.HiddenConstraints = "scope:" + "\"" + SearchScope + "\"";
keywordQuery.TrimDuplicates = true;
keywordQuery.EnableStemming = true;
keywordQuery.IgnoreAllNoiseQuery = true;
keywordQuery.QueryText = "SELECT AccountName,PreferredName,PictureUrl,WorkEmail,JobTitle,Department,InternalNumber,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,InternalTelephone,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,HitHighlightedProperties,CollapsingStatus,Path,FirstName,LastName FROM Scope() WHERE ('scope'='People')";
keywordQuery.EnablePhonetic = true;
keywordQuery.ResultsProvider = SearchProvider.Default;
keywordQuery.ResultTypes = ResultType.RelevantResults | ResultType.SpecialTermResults ;
ResultTableCollection resultsTableCollection = keywordQuery.Execute();
ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];
DataTable resultsDataTable = new DataTable();
resultsDataTable.TableName = "Results";
resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);
DataView view = new DataView(resultsDataTable);
SearchGrid.DataSource = resultsDataTable;
SearchGrid.DataBind();
}
No comments:
Post a Comment