Set SharePoint search suggestions

26/03/2015 13:09

In case we want to hardcode search suggestions for sharepoint search box, we can use following code:

It's working in SharePoint 2010, uncomment $searchOwner parameter and its call for SharePoint 2013 (in 2013 it's required)


Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$siteUrl = https://yoursitecollection
$searchapp = Get-SPEnterpriseSearchServiceApplication

$searchapp

$site = Get-SPSite $siteUrl
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search");
#$searchOwner = New-Object Microsoft.Office.Server.Search.Administration.SearchObjectOwner([Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::Ssa, $site.RootWeb)

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "testik" #-Owner $searchOwner

Start-SPTimerJob -Identity "Prepare query suggestions"
"Finished."


Then, when you start writing 'test', 'testik' is suggested.