Deprecated: YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container::__construct(): Implicitly marking parameter $parameterBag as nullable is deprecated, the explicit nullable type must be used instead in /home/nubelus/sharedove/adisjugo/wp-content/plugins/wordpress-seo/vendor_prefixed/symfony/dependency-injection/Container.php on line 60
Utilizing the People Search in SharePoint 2010 - Adis Jugo blog
Select Page

Utilizing the People Search in SharePoint 2010

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.

Previous

Next