A short and effective way to utilize SharePoint People Search in your own applications is using SharePoint Server Object Model and Microsoft.Office.Server.Search namespace.
People search works the same way any other SharePoint search does – we search in the scope, in this case – in the “People” scope.
FullTextSqlQuery qry = new FullTextSqlQuery(SPContext.Current.Site);
qry.ResultTypes = ResultType.RelevantResults;
qry.QueryText = "SELECT preferredname,workemail,description ";
qry.QueryText += " FROM SCOPE() WHERE "scope" = '" + "People" + "' ";
qry.QueryText += " AND FREETEXT(*, '" +
yourSearchQuery + "')";
ResultTableCollection rtq = qry.Execute();
if (rtq.Count > 0)
{
ResultTable queryResultsTable = rtq[ResultType.RelevantResults];
int totalResults = queryResultsTable.TotalRows;
DataTable tableResults = new DataTable();
tableResults.Load(queryResultsTable, LoadOption.OverwriteChanges);
}
We can get the possible field names for the SELECT statement from the mapped properties – just check which properties are used in the “People” scope.