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-throughs 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 "<SearchServiceApplicationName>"
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.

avatar

About Adam Preston

Adam is a Senior Consultant specializing in the administration and configuration of SharePoint. He holds several SharePoint certifications, including MCITP: SharePoint Administrator 2010. He is the Vice President of the Richmond SharePoint Users Group and active throughout the SharePoint community via Twitter (@_apreston) and MSDN Forums.
This entry was posted in Configuration, PowerShell and tagged , , , . Bookmark the permalink.

3 Responses to Create Query Suggestions and Related Searches in SharePoint Server 2010

  1. Pingback: Create Query Suggestions and Related Searches in SharePoint Server 2010 « SP2010 Blog

  2. avatar dylan says:

    We had problems with Query Suggestions not populating automatically. Spent weeks even months trying to get it working, including Microsoft Support getting involved (they could reproduce the issue, but did not know how to fix it.) Turns out at some stage Query Logging was disabled on the Search Service Application. It would be nice if more sites mentioned the relationship. (I’m posting this here just in case somebody else has this problem!)

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>