SharePoint Use Cases

  • Home
  • About
  • Our Tools
  • Contact me
SharePoint 2010

Auto populate Search suggestions for SharePoint People Search

Toni Frankola - August 9, 2012

One of mine customers wanted to replace their existing phone directory with the SharePoint OOTB user profiles. They already had all the data in the Active Directory and also had pictures for most employees, so SharePoint sounded like an obvious choice. One of the requests was to have search as you type suggestions for people search. The good news is: this already exists in SharePoint, you just just need some PowerShell magic to work correctly.

SharePoint People Search As You Type

A note from the official documentation:

Query suggestions depend on users’ searches. Only search queries that have been previously returned and then clicked through at least six times will appear in either the search box list or the Related Queries Web Part. Therefore, a newly deployed SharePoint Server 2010 system will not show query suggestions in either location. Moreover, a query suggestion will only appear in the search box list or the Related Queries Web Part if the query suggestion contains at least one of the words that are typed.

This is what you need to do to configure this for your environment:

1. Execute the following script in your environment. For parts of this script I used this script by Daniel Root). Make sure you change to match your Search Service Application name (line 22) before exacting.

cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
	Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

function Enumerate-SPUserProfiles($SearchServiceApp)
{
	$x= [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
	$x= [System.Reflection.Assembly]::LoadWithPartialName("microsoft.sharepoint.portal")
	$x= [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
	$x= [System.Reflection.Assembly]::LoadWithPartialName("System.Web")

	$sites = Get-SPSite
	$context = [Microsoft.Office.Server.ServerContext]::GetContext($sites[0])
	$profileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
	# gets all the user profiles, those that have domain\username as DisplayName are excluded
	$profileManager.GetEnumerator() | ?{$_.DisplayName -notlike '*\*' } | foreach-object { Add-SPSuggestion $SearchServiceApp $_ } |
}

function Add-SPSuggestion($SearchServiceApp, $User)
{
	New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name $User.DisplayName
}

#Change to match your Search Service Application Name
$searchapp = Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application"

Enumerate-SPUserProfiles
Start-SPTimerJob -Identity "prepare query suggestions"

2. Navigate to your Search Center > People Search page

3. Edit People Search Web Part properties

4. Check the Show query suggestion option

Show Query Suggestions

5. Save Page

That’s it! You are done!

Tags | powershell, search, user-profiles
 0
Share Now

Toni Frankola

Entrepreneur, IT consultant, speaker, blogger, and geek. Co-founder of syskit.com.

You Might Also Like

SharePoint

SSO and Sharepoint

July 10, 2007
SharePoint

Search Server 2008 first impressions, roadmap and opportunities

January 2, 2008
SharePoint

Configuring scopes in Microsoft Search Server 2008

October 19, 2008
SharePoint

Configuring Scopes Dropdown

November 20, 2008

2 Responses

  • Andy September 17, 2014 at 3:36 pm

    Hi,
    Great article, thanks! Any idea how the list is sorted? Is it possible to sort by surname, name?

    Thanks and best regards
    Andy

  • Bijomon November 3, 2014 at 10:56 am

    Dear,
    Can you help me to show contacts in people search in 2013
    Below post was done on 2010
    http://johnliu.net/blog/2012/9/25/sharepoint-showing-contacts-in-people-search-results.html?lastPage=true&postSubmitted=true

  • Comments are closed.

    Previous Post Sync your files to SharePoint 2013 or Office 365
    Next Post Use cases for Documentation Toolkit for SharePoint

    Archives

    • December 2021 (1)
    • June 2021 (1)
    • January 2021 (1)
    • July 2019 (1)
    • June 2019 (2)
    • March 2019 (1)
    • February 2019 (3)
    • October 2018 (2)
    • August 2018 (2)
    • June 2018 (1)
    • April 2018 (1)
    • February 2018 (1)
    • January 2018 (1)
    • June 2017 (1)
    • April 2017 (1)
    • February 2017 (1)
    • November 2016 (2)
    • August 2016 (1)
    • July 2016 (2)
    • March 2016 (1)
    • February 2016 (2)
    • January 2016 (1)
    • November 2015 (2)
    • December 2014 (1)
    • November 2014 (2)
    • July 2014 (2)
    • June 2014 (2)
    • May 2014 (1)
    • April 2014 (2)
    • March 2014 (1)
    • February 2014 (4)
    • January 2014 (2)
    • December 2013 (1)
    • September 2013 (1)
    • July 2013 (1)
    • June 2013 (1)
    • May 2013 (1)
    • April 2013 (3)
    • February 2013 (1)
    • December 2012 (1)
    • November 2012 (1)
    • September 2012 (1)
    • August 2012 (1)
    • July 2012 (2)
    • June 2012 (4)
    • April 2012 (1)
    • February 2012 (1)
    • January 2012 (1)
    • November 2011 (2)
    • October 2011 (2)
    • September 2011 (2)
    • July 2011 (3)
    • May 2011 (2)
    • April 2011 (1)
    • March 2011 (4)
    • February 2011 (3)
    • January 2011 (4)
    • December 2010 (4)
    • November 2010 (3)
    • October 2010 (3)
    • September 2010 (4)
    • August 2010 (1)
    • July 2010 (4)
    • May 2010 (2)
    • April 2010 (2)
    • March 2010 (3)
    • January 2010 (2)
    • December 2009 (3)
    • November 2009 (5)
    • October 2009 (2)
    • August 2009 (7)
    • July 2009 (3)
    • June 2009 (4)
    • May 2009 (3)
    • April 2009 (5)
    • March 2009 (8)
    • February 2009 (5)
    • January 2009 (8)
    • December 2008 (9)
    • November 2008 (8)
    • October 2008 (7)
    • September 2008 (4)
    • August 2008 (6)
    • July 2008 (5)
    • June 2008 (3)
    • May 2008 (4)
    • April 2008 (6)
    • March 2008 (4)
    • February 2008 (3)
    • January 2008 (6)
    • December 2007 (1)
    • November 2007 (3)
    • October 2007 (3)
    • September 2007 (2)
    • August 2007 (1)
    • July 2007 (12)
    • June 2007 (2)
    • May 2007 (3)

    Connect Us

    All postings on this blog are provided “AS IS” with no warranties, and confer no rights. All entries in this blog are my opinion and don’t necessarily reflect the opinion of my employer.

    • Home
    • About
    • Our Tools
    • Contact me

    Copyright (c) Toni Frankola 2008. - 2019.