One of the great new features around Search in SharePoint 2010 is the concept of query suggestions. There are pre-query and post-query suggestions. A pre-query suggestion is a type-ahead feature that appears in the search box on the search page. As you start typing in your query, SharePoint will go find other queries that have been executed with results and populate the type ahead drop down for you. We only use queries that return results so we don't suggest something that will bring back zero matches. A post-query suggestion is similar, only it appears after you have executed a query. It finds similar queries that have been executed and return results, and it displays them by default in the top right corner of the search results page. Clicking on a post-query suggestion will execute that query for you.
One of the important things to remember about query suggestions though is that since they are built based on user's performing searches and clicking through results, when you start out with your SharePoint farm you will not see any suggestions. I'm going to show you how to seed the suggestions manually to get things going. The suggestions you add in this manner show up as both pre-query and post-query suggestions. Adding them manually is useful for getting this started or just seeing how the feature works; you may also have some set of query suggestions that you ALWAYS want to show up no matter what query is executed. Also note that these steps were tested and work on the SharePoint escrow build (you TAP and RDP customers know which one this is) but I don't think they work on the public beta bits. This will be good info though for everyone once you have RTM bits. One final note - this process *should* work for both SharePoint Search and FAST Search for SharePoint. So here are the steps:
Now the next thing you want to do is run a timer job. The timer job is called Prepare query suggestions and it is scheduled to run once a day. Run it now to get it to process your suggestion.
One way you can verify if your suggestion was added successfully is to use this PowerShell command:
Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApplication $ss
That will show you the Always Suggest words; of course, you can and should go try it out in the browser as well. Finally, you may add one and decided that you want to remove it; we can do that too. Here's the PowerShell command for that:
Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ss -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity "SharePoint Server 2010"
Note the main difference is the last parameter name. When you are adding a suggestion, the last parameter is called "Name"; when you are removing it the parameter is named "Identity". Also, don't forget to run the timer job after you remove an entry. It may take a few minutes after running the timer job to see the updated results.
Thanks! I needed to do exactly this and remembered seeing this post- very helpful. Any idea how many of these suggestions we can load up? We're considering adding a few thousand from a customer dataset. We'll test, but I was wondering if you knew of any upper limit.
Hi thanks, this post was very helpful. Do you know if there is a way to automatically populate this list based on user queries? Manually adding all possible phrases in my installation is impossible.
Thanks for the great information!
Thanks for the post. I'm getting my feet wet in 2010. Can you confirm the type ahead feature works in Search Enterprise edition? The not FAST or Not Foundation version. Currently I'm not getting any per or post type ahead or suggested results...
Thanks this was helpful. but I have few queries, Can we create only one query suggest in sharepoint 2010. Say for example: I'm creating a query suggest named "A" , and start the timer job. Again if I'm creating another query suggest named "B", and start the timer job.. Then how to differentate which one is running.
And also I have a requirement to use many query suggestion.
Please help me to clarify this. Thanks!!
How to access the query suggestions we have uploaded in sharepoint 2010 for custom text box....
Please let us know ...thanks.....
Do Sharpoint 2011 have suggestion box?.
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!)