Editing People Search Results

Now I will be talking about how to display additional properties of User inside people search results.

Points to remember:

1. Ensure that properties that you want to appear are currently being listed out in the search API results.

Use the http://server/_api/search/query?querytext=”&sourceid=’GUID OF PEOPLE SOURCE’&selectproperties=’AccountName,ABG_Property1,ABG_Property2′

2. If required properties are not being listed in the browser’s XML/JSON output, it means that the custom UPS properties do not have managed properties defined. Now you need to create a new Managed Property inside Search schema & point it to appropriate UPS’s crawled property. Then a FULL crawl is mandatory.

Now check the search API in the browser & then properties should be listed at least. Go & edit the UPS property for a user & do a incremental crawl & now both property & value should come up. Now is the time to create next SharePoint artefact.


DISPLAY TEMPLATES:

In SP 2013, the search results are now rendered using HTML/JS files which are called Display Templates. Here HTML is the actual Display Template while .JS is created automatically by SP when a HTML is uploaded.

This HTML will contain both UI part and JS part. The JS alone will be encapsulated inside special SP tags. Once the HTML file is uploaded, SP will automatically create a JS after reading the HTML.

  1. Go to Site Settings -> Master page & Page layout Gallery -> Display Templates -> Search -> Download a copy of Item_Person.HTML
  2. Now rename the file to ABG_Person.html & look inside it.
  3. At the top there will be a definition of the list of FIELDS. Just go there & start adding up the new Managed properties. The list of fields will be defined inside a tag like:<mso:ManagedPropertyMapping

3

  1. Now in the middle you can append you required HTML UI elements as needed.
  2. Save the file & upload it in the same path as downloaded.

Now in the Upload screen, choose below options:

12

Now SAVE & PUBLISH the .HTML file.


RESULT TYPES:

Result types are the ones which define which display template need to be used for which result. Now go the result type settings page: https://server/_layouts/15/manageresulttypes.aspx?level=site

  1. Here click the Person’s dropdown menu & select COPY
  2. Enter the new result type details as below

Name as “ABG Person New”

Which Source should Results match: Local People Results

What should these results look like: here choose ABG People Item.

Once the above is done click SAVE.


RESULTS WEB PART:

Now its time to piece all together & make it work.

  1. Edit the page containing the people results web part
  2. Inside the web part properties, click on the Display Templates & choose the result type as “ABG Person New”, click OK & then save the page.

And finally perform search & viola you get the additional properties now.

capture

 

That is all for now. In another post I will explain about how to edit the search results’s Query Builder where you define from where the SEARCH KEYWORD should be taken. Like should it be a search textbox or some Custom URL parameter…..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: