Tip 34: Adding a SharePoint 2010 Search Suggestion


This tip is for SharePoint Server 2010, Search Server 2010 and Search Server 2010 Express.

SharePoint Server 2010 and Search Server 2010 Express include a new feature for search called Search Suggestions. Search suggestions are listing below the search box that suggests search terms while you are typing your search query. They have been around for a few years in sites like www.bing.com and are now integrated into SharePoint 2010. Below is a screenshot of a SharePoint Enterprise Search Center site with a suggestion.

SearchSuggestion

Suggestions are automatically built based on what search results are actually clicked on. It takes 6 clicks within a year for SharePoint to add a suggestion; if an administrator needs to add a suggestion manually this can be done using the SharePoint 2010 Management Shell (PowerShell). The commands below will add the suggestion, “Suggestion” to the first Search Service Application and run the Prepare Query Suggestions timer job now. The Prepare Query Suggestions timer job is set to run daily between 1AM and 11PM local server time so this will speed up the time before the suggestion will appear in the search query suggestions list.

$ssa=Get-SPEnterpriseSearchServiceApplication

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Name “Suggestion”

$timer=Get-SPTimerJob|? {$_.Name -eq “Prepare Query Suggestions”}

$timer.RunNow()

After the above commands have been run and the timer job has been run, the suggestion and other suggestions in a Search Service Application can be listed by running the following command from the SharePoint 2010 Management Console.

Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApp $ssa

To remove the suggestion, run the following command.

Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity “Suggestion”

Comments (10)

  1. Yael C says:

    "Suggestions are automatically built based on what search results are actually clicked on. It takes 6 clicks within a year for SharePoint to add a suggestion;"

    The automatically query suggestions does not work, I try to run the same query a few times, and restart the "Prepare query suggestions" job. Should I enable that feature? or set the configuration?

    Thanks for the help.

  2. Nick Larter says:

    If you have more than one FAST Query Service installed, you can add your query suggestion to a specific one like this:

    $ssa = Get-SPEnterpriseSearchServiceApplication -Identity "FAST Query SSA – Intranet"

    The -Identity value is just the title string of the service.

  3. Rao says:

    How frequently if will run the default search suggestions. Even after 6 clicks doesn't show the suggestion.

  4. Martin says:

    Hi, thanks for this post.

    I used your code and added the word "pop" to my suggestions. Everything works fine and the word "pop" is suggested when I type "po" into the search text box.

    Then I also added the word group "pop up" to the suggestions. Now, when I type "po" into the search text box only "pop up" is suggested, but "pop" is missing.

    "art" and "article" works fine.

    It seems like SharePoint skips a short suggestion, if there is a longer one that starts with the same letters followed by an empty space.

    Of course I configured that more than one suggestions shall be displayed (8 on default).

    Could this be an unknown SharePoint bug?

    Greetings

    Martin

  5. Dylan says:

    I'm having the same trouble as a couplke of other posters above. No matter what we do, since the last SP update, we are not getting any new entries in the suggestions list. How could I verify that this is working (or not?)

    (I can manually add entries fine, it just seems that the automatic addition of items is not working. Could it be an IE thing?)

  6. stephen says:

    Thanks the post Chad. However, Querry Suggestions are severly limited by not being able to use them on the Advanced Search Web Part. Do you know of a way of doing so?

  7. Ramesh says:

    Hi I am new in to SharePoint, my requirement is auto suggestions in the enterprise search , when I type "sha" into the search text box only "share…." is suggested.

    please help me

    any one please provide step by step how to do in sharepoint 2010 enterprise search

    Warm Regards,

    Ramesh

  8. Prip says:

    Hi, I am getting an error A given key is not present in the dictionary when I run the command :

    Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity "christopher"

    where Christopher is automatically added query suggestion

  9. FS says:

    How do I know what "-Language ID" to use. "En-Us" does not remove any suggestions, only if I ADD suggestions with this -Language type. Please help.

  10. Venkat says:

    How do I deleted all the query suggestions stored in the MSSQLogQueryString. We dont use the "Suggestion " feature in our application. The size of the table has grown enormous to 200 GB .