Wednesday, October 17, 2012

SharePoint 2010 - Search Suggestions: Add/Remove Terms

Search suggestions are one of the key features of SharePoint 2010 search. One lack of functionality is, that you can manage them only by PowerShell.

Overview Search Suggestions concept: http://sharepointfieldnotes.blogspot.ch/2011/09/sharepoint-2010-search-query.html

Best Script to add suggestions based on a csv file input: http://get-spscripts.com/2010/07/add-pre-query-search-suggestions-with.html

ADD Suggestions (Script from get-spscripts.com):

#Set up default variables
$csvfile="C:\Install\SearchSuggestions.csv"
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" #Create Lists from each item in CSV file
$csvData = Import-Csv $csvfile
foreach ($line in $csvData)
{
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Name $line.Suggestion
} $timerJob = Get-SPTimerJob "Prepare query suggestions"
$timerJob.RunNow()


REMOVE Suggestions (modified script from get-spscripts.com):

#Set up default variables
$csvfile="C:\Install\SearchSuggestions.csv"
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" #Create Lists from each item in CSV file
$csvData = Import-Csv $csvfile
foreach ($line in $csvData)
{
     Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Identity $line.Suggestion
} $timerJob = Get-SPTimerJob "Prepare query suggestions"
$timerJob.RunNow()

Note: Search suggestions are added trught the Timer Job "Prepare query suggestions", no reindexing is required after modifications.

Hint: To avoid problems with special characters, please import the CSV as UTF-8. ANSI will end up in unknow special characters.

No comments:

Post a Comment