Tuesday, August 7, 2012

How To Create Query Suggestions and Related Searches in SharePoint Server 2010

You have seen query suggestions and related searches on every popular search web site. A query suggestion is that drop down that displays when you start typing a few letters in the search box:

 

Related searches are on the results page notifying the user of other possible search queries:


Did you know that SharePoint Server 2010 offers this same functionality? You may not for quite some time. This is because the suggestions and related searches are not added and will not display until a result for that search has had at least six result click-through by users. So, for new deployments of SharePoint Server 2010 it could be a while until suggestions start showing. To overcome this and create a starting point for our new SharePoint Server 2010 deployment, we can manually create query suggestions via PowerShell and have that start showing immediately.

Our fictitious company, Orion, makes and sells various media equipment like DVD players, TVs, and etc. Let’s run through a scenario where I want the users to be able to easily find documents related to our company’s products.

Open up the SharePoint 2010 Management Shell and run the following commands, substituting in your Search Service Application name and suggested queries:


$SearchApp = Get-SPEnterpriseSearchServiceApplication -Identity ""
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ORN-DVD500"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ORN-HDTV2000"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ORN-BLURAY100"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ORN-XDRIVE1TB"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "External Drive"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "DVD Player"
Start-SPTimerJob -Identity "prepare query suggestions"

Once the timer job completes, we can run an additional command to retrieve the query suggestions to make sure they were added properly:


Get-SPEnterpriseSearchQuerySuggestionCandidates –SearchApplication $SearchApp

Now, navigate to the search site and type the first few letters of a newly added query suggestion.
To test the related searches, you can do a search for parts of a query suggestion. Note the Related Searches on the right:


This will get your new SharePoint Server 2010 deployment off the ground running with a better search user experience.

No comments:

Post a Comment