SharePoint Search Webparts





People Search Core Results Web part

I have been asked by my client to to browse/show a people directory within the organisation unit without having to enter a search query. They then want to see a list of filters such as Department or Job Title to allow them to filter the results. This is really easy to set up using the default SharePoint 2010 search web parts and doesn’t require writing a single line of code

The standard search result web part does not show any results unless a query is specified. To get all people to show up by default we need to specify either a fixed keyword query or append text to the query in the People Search Core Results web part properties. If we specify a fixed keyword query the web part will always display results for the specified search query on the page regardless of whether the user has entered a search query. If we select append text to query then when the user types a query we will see results from a search query that includes both the text the user entered and the text in the web part properties. For our people directory we can use this to show a default set of results (i.e. all people) but let the user refine this further by entering text (e.g. a person’s name or a department). The query we need to enter to retrieve all people is contentclass:spspeople.

 



Here I user Append Text to Query as: level1:"corpe"


Expand Display Properties: Change the Fetched properties and the XSL in XSL Editor.  This xsl for people core search results webpart can be downloaded from msdn or below link
http://chinthamahesh.blogspot.in/2012/11/xsl-for-sharepoint-2010-people-core.html 


And, uncheck “Use Location Visualization “check box
 

Update the XSL as per the attached style sheet and update the columns as per the columns xml.

 

<Columns>  <Column Name="WorkId"/>  <Column Name="UserProfile_GUID"/>  <Column Name="AccountName"/>  <Column Name="PreferredName" HitHighLight="true"/>  <Column Name="YomiDisplayName" HitHighLight="true"/>  <Column Name="JobTitle" HitHighLight="true"/>  <Column Name="Department" HitHighLight="true"/>  <Column Name="WorkPhone" HitHighLight="true"/>  <Column Name="OfficeNumber" HitHighLight="true"/>  <Column Name="PictureURL"/>  <Column Name="HierarchyUrl"/>  <Column Name="WorkEmail" HitHighLight="true"/>  <Column Name="Path"/>  <Column Name="HitHighlightedSummary"/>  <Column Name="HitHighlightedProperties"/>  <Column Name="Responsibility" HitHighLight="true"/>  <Column Name="Skills" HitHighLight="true"/>  <Column Name="SipAddress" HitHighLight="true"/>  <Column Name="Schools" HitHighLight="true"/>  <Column Name="PastProjects" HitHighLight="true"/>  <Column Name="Interests" HitHighLight="true"/>   <Column Name="OrgNames" HitHighLight="true"/>  <Column Name="OrgUrls"/>  <Column Name="OrgParentNames" HitHighLight="true"/>  <Column Name="OrgParentUrls"/>  <Column Name="Memberships" HitHighLight="true"/>  <Column Name="AboutMe" HitHighLight="true"/>  <Column Name="BaseOfficeLocation" HitHighLight="true"/>  <Column Name="ServiceApplicationID"/>  <Column Name="SocialDistance"/></Columns> 

Finally It should be as below:

 


People Refinement Panel:


People refinement panel is used to display the refiners for the search web part. Refiners can be configured in “Filter Category Definition” in Refinement section.

Uncheck “User Default Configuration” when the refiners are customized.

It is always better to export the web parts from search center and import in the new pages while creating the people directory.

Filter Category Definition:
Basically this XML file defines which refiners will be shown for result sets. But this is what is important. If you are customising this XML file then MAKE SURE THAT THE USE DEFAULT CONFIGURATION OPTION IS FALSE

Below is the Refiners xml:
 
<?xml version="1.0" encoding="utf-8"?><FilterCategories><Category    Title="Level 2"    Description="Which level2 this document is from"    Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"    MetadataThreshold="5"    NumberOfFiltersToDisplay="4"    MaxNumberOfFilters="20"    SortBy="Frequency"    SortByForMoreFilters="Name"    SortDirection="Descending"    SortDirectionForMoreFilters="Ascending"    ShowMoreLink="True"    MappedProperty="level2"    MoreLinkText="show more"    LessLinkText="show fewer"/>    <Category    Title="Level 3"    Description="Which level3 this document is from"    Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"    MetadataThreshold="5"    NumberOfFiltersToDisplay="4"    MaxNumberOfFilters="20"    SortBy="Frequency"    SortByForMoreFilters="Name"    SortDirection="Descending"    SortDirectionForMoreFilters="Ascending"    ShowMoreLink="True"    MappedProperty="level3"    MoreLinkText="show more"    LessLinkText="show fewer" />  <Category    Title="Department"    Description="Which site this document is from"    Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"    MetadataThreshold="5"    NumberOfFiltersToDisplay="4"    MaxNumberOfFilters="20"    SortBy="Frequency"    SortByForMoreFilters="Name"    SortDirection="Descending"    SortDirectionForMoreFilters="Ascending"    ShowMoreLink="True"    MappedProperty="Department"    MoreLinkText="show more"    LessLinkText="show fewer" /><Category    Title="Location"    Description="Which site this document is from"    Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"    MetadataThreshold="5"    NumberOfFiltersToDisplay="4"    MaxNumberOfFilters="20"    SortBy="Frequency"    SortByForMoreFilters="Name"    SortDirection="Descending"    SortDirectionForMoreFilters="Ascending"    ShowMoreLink="True"    MappedProperty="Location"    MoreLinkText="show more"    LessLinkText="show fewer" />   </FilterCategories>  

Update the “Filter Category Definition” as per the attached Refiners xml.






Accuracy Index:
The accuracy index number is the number of results used to calculate the refiner counts. Now this is usually not turned on in default SharePoint 2010 search and if the number is lower than the total result set then you might get false numbers returned for refiners.
If the accuracy index is 500, the refiners will be generated from the first 500 results. The max value of accuracy index is 500 in SharePoint search.

Number of Categories to Display:
If you define a refiner in the Filter Category XML that it will not automatically appear due to the Metadata threshold. The number of categories to display is the number of refiners generated. Refiners are basically rendered in the order they are in the XML so if you put your refiner at the end and already the refinement panel has rendered the maximum amount it won’t be seen by users.

Result Query Options:
Set the results query options to “User Query” as same as search web part
Refinement panel with custion refiners
 

  

Search Statistics:

Search statistics web part display the result count for each page. We need to set the “Cross web part query” as same as the search web part to display the correct result count. 

 

Cross Web part query ID:
Set the cross web part query id to “User query” as same as search web part.


Search Paging:

 

Search paging web part is to enable the paging for the search result. By default paging is not enabled for the search web part. We need to add the search paging web part to enable the paging.
Set the “Cross web part query” as same as the search web part to enable the paging.

Cross Web part query ID:
Set the cross web part query id to “User query” as same as search web part.





Done!!
 


 



 

Comments

Popular posts from this blog

Create and Deploy custom copilot to SharePoint Site (Part 2)

Create and Deploy custom copilot to MS Teams and SharePoint Site (Part 1)

Copilot Announcements from Microsoft Build 2024