I’ve had a few clients ask for a page on their intranet that allows users to browse a list of people within the organisation 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. An example of what this can look like is shown below (note no query is specified, we have just clicked on the ‘people directory’ link in the top nav):
Especially when the organisation only contains a few hundred people this can help users discover people in the organisation without necessarily knowing their names. The steps to create this are as follow (assuming the user profile and search services are running successfully):
- Assuming you have an enterprise search center set up the first step to create the people directory is to create a new page. This can be done by navigating to the pages library and selecting New Document > Page from the ribbon.
- On the create page screen select the People search results page layout to create a page that contains the people search results web parts.
- 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.
- We now have a list of people that will be displayed as soon as the user navigates to our custom people results page. By default we also have some refinements that appear if matching metadata is found within the result set. These are View matches by Name or Profile, Job Title, Organization and Managed Metadata columns (these pull out information such as Past projects, Ask Me About and other Managed Metadata fields contained in the edit profile screen). We can change these to show other metadata properties that are defined in our search centre. Some other properties that might be relevant are Department, Job Title and/or Past Projects.
- [Update 10 June 2011] Note that the default Department managed property does not work correctly when used in the refinement panel (no results are displayed). To get this to work we need to create a new managed property that maps to the People:Department crawled property. This involves navigating to the ‘Metadata properties’ page of your search service application and creating a new Managed property. In this example I’ve named it DepartmentRefinement and mapped it to the People:Department(Text) property as shown below.
- To change these we can edit the ‘Filter Category Definition’ property of the refinement panel to include the XML shown below. [Updated 10 June 2011 to correct department refinement]
- The important things to note here is that we are adding a new Category element with Title=Department (this will be used as the category heading) and MappedProperty=DepartmentRefinement. The MappedProperty attribute needs to match a managed property in the search service application.
Department is added as a managed property by default butif you want to include other properties such as Office you will need to make sure there is a managed property that contains this information.
- To ensure our custom Filter Category Definition is used we also need to ensure the Use Default Configuration is unchecked. Optionally we can also change the Accuracy Index to tweak the number of results that are inspected to generate refinements (higher values incurring a greater performance penalty but making refinements more accurate). For more details see the article “Change what appears in the Refinement Panel Web Part” on TechNet.
- Once this is in place we get an updated refinement panel and we now have a simple people directory page that people can use to discover individuals within the organization without having to enter a search query.
This isn’t the most sophisticated people directory but it can be achieved in a few minutes without writing any code. With a little more effort we could change the rendering of the results (so they are displayed in a table layout for example) or provide additional filtering options such as an A-Z filter on the name field. If anyone is interested or has made other interesting additions to this search driven people directory please let me know in the comments below.