Share via


Manage query suggestions (Search Server 2010)

 

Applies to: Search Server 2010

Topic Last Modified: 2011-04-29

Query suggestions, also known as search suggestions, appear in a list below the Search Box Web Part and on the search results page in the Related Queries Web Part. You can turn off query suggestions so that they will not appear at query time, and you can manually create query suggestions. When you use Windows PowerShell to manually add query suggestions, you immediately provide the benefits of query suggestions to users of a newly installed search system. You can also supplement the default Microsoft Search Server 2010 behavior by adding query suggestions for key search terms. In this manner, you can provide query suggestions that might not be generated by the system because users are not using the search terms that would create the query suggestions that you want to appear.

Query suggestions depend on users' searches. Only search queries that have been previously returned and then clicked through at least six times will appear in either the search box list or the Related Queries Web Part. Therefore, a newly deployed Search Server 2010 system will not show query suggestions in either location. Moreover, a query suggestion will only appear in the search box list or the Related Queries Web Part if the query suggestion contains at least one of the words that are typed.

You can configure how query suggestions appear below the search box. You do this in the Query Suggestions node of the Search Box Web Part menu. For more information about the Search Box Web Part, see Change properties for the Search Box Web Part (Search Server 2010).

You can configure the Related Queries Web Part on the search results page in the same manner that you configure other Web Parts. In addition, you can configure the following:

  • Query Suggestion Results - Allows configuration of Results per Page, Characters in Summary and provides access to an XLS Editor and Parameters Editor.

  • Results Query Options - Allows enable/disable of search term stemming.

How to configure query suggestions

Query suggestions are automatically created over time for any query that has a specified number of result click-throughs. By default, a query suggestion is created after users click through six times. The suggestions are compiled by the Prepare query suggestions timer job in Central Administration, which is scheduled to run one time every day. By default, query suggestions are turned on. You can turn this feature off or configure the default settings by editing the Search Box Web Part.

Even if you turn off query suggestions on the Search Box Web Part menu, related searches still will appear on the search results page in the Related Queries Web Part.

To configure query suggestions

  1. Verify that the user account that is performing this procedure is a site owner on the Search Center site.

  2. On the Search Center site home page, click Site Actions, and then click Edit page.

  3. On the Search Box Web Part menu, click Edit Web Part.

  4. Expand the Query Suggestions node.

  5. Make sure that the Show query suggestions box is selected. If you want to turn off query suggestions, clear the Show query suggestions check box.

  6. If required, change the following settings:

    • Minimum prefix length: The number of letters the user must type before query suggestions are displayed.

    • Suggestion delay (in milliseconds): The number of milliseconds to elapse before query suggestions are displayed.

    • Number of suggestions to display: The number of query suggestions to display in the list.

  7. Click OK.

How to create query suggestions by using Windows PowerShell

The following procedure shows how to manually create query suggestions for a newly deployed Search Server 2010 installation by using Windows PowerShell. You can also use this procedure to add query suggestions to an existing Search Server 2010 installation when you want to include a list of suggestions that are independent of search usage. These query suggestions will appear below the search box and in the Related Queries Web Part. Query suggestions that you create by using this procedure will appear immediately after you run the commands.

To manually create query suggestions

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. On the Start menu, click All Programs.

  3. Click Microsoft SharePoint 2010 Products.

  4. Click SharePoint 2010 Management Shell.

  5. At the Windows PowerShell command prompt, type the following commands:

    Get the current Search service application:

    $searchapp = Get-SPEnterpriseSearchServiceApplication -Identity "<SearchServiceApplicationName>"
    

    Display all current query suggestions:

    Get-SPEnterpriseSearchQuerySuggestionCandidates -SearchApplication $searchapp
    

    Add a query suggestion:

    New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -<Language ID> -Type QuerySuggestionAlwaysSuggest -Name "<Suggestion>"
    

    Run the prepare query suggestions timer job:

    Start-SPTimerJob -Identity "prepare query suggestions"
    

    Remove a query suggestion:

    Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language <Language ID> -Type QuerySuggestionAlwaysSuggest -Identity "<Suggestion>"
    
  6. Repeat the New-SPEnterpriseSearchLanguageResourcePhrase cmdlet for each query suggestion that you want to add. As a best practice, you should run the Start-SPTimerJob cmdlet only after you have added all the query suggestions that you want.

Add multiple query suggestions example

The following example shows how to add a group of query suggestions in which the letters "test" are part of every query suggestion.

$searchapp = Get-SPEnterpriseSearchServiceApplication -Identity "<SearchServiceApplicationName>"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "refinement test"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test case"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test case alpha"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test case beta"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "really long query suggestion test"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "tester"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test refinement cases"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test short"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test shorty"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "short"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "acceptance test"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ecm test"
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test three"
Start-SPTimerJob -Identity "prepare query suggestions"