Product DocsMenu

Configuring Query Suggestions for Scarce Results in a .NET Search Interface

Coveo .NET Front-End 12.0.404+ (October 2013)

The Coveo .NET Front-End out-of-the-box search interfaces feature query suggestions when a query returns no or only a few results. Query suggestions can be of different types (see About Query Suggestions for Scarce Results in .NET Search Interfaces). A query suggestion indicates the type, the number of results, and optionally sample results.

The query suggestion proposition
The number of returned results
Optional sample results

Note: The feature is available and activated by default in most out-of-the-box .NET search interfaces but not mobile .NET search interfaces.

Query Suggestions Skin Templates

The query suggestion is defined in ASCX files in the respective skin folders. The query suggestion skin template location and content varies depending on the type of skin.

Normal skin

The query suggestion template for all .NET search interface skins is located in the ResultsPanel.ascx file after the <ces:NoResultsAdvices> section.

<%-- Query suggestions are displayed when there are few or no results --%>
<ces:QuerySuggestions id="sug" CssClass="CesQuerySuggestions" DisplaySampleResults="True" runat="server">
  <SuggestionTemplate>
    <div class="CesQuerySuggestion">
      <ces:QuerySuggestionLink runat="server" />
      <ces:QuerySuggestionSampleResults runat="server">
        <SampleResultTemplate>
          <ces:DefaultResultTemplate TemplatePath="SuggestionSampleResult.ascx" runat="server"/>
        </SampleResultTemplate>
      </ces:QuerySuggestionSampleResults>
    </div>
  </SuggestionTemplate>
</ces:QuerySuggestions>  

Outlook skin

The query suggestion template for the Outlook skin is located in the CoveoSearch.ascx file in the <ces:IfNoResults> section. In this skin, query suggestions will only be shown if there are no results returned. Sample results are disabled by default in Outlook skins.

<%-- Query summary (only if no results) --%>
<ces:IfNoResults runat="server">
  <ces:QuerySummary id="$Prefix$qsm" CssClass="CesQuerySummary" runat="server" />
  <ces:NoResultsAdvices CssClass="CesNoResultsAdvices" style="margin-top: 10px;" runat="server" />
  <ces:QuerySuggestions DisplaySampleResults="False" SortAscending="True" runat="server">
    <SuggestionTemplate>
      <div>
        <ces:QuerySuggestionLink runat="server" />
      </div>
    </SuggestionTemplate>
  </ces:QuerySuggestions>
</ces:IfNoResults>  

Console skin

The query suggestion template for the console skin used in the Account Console and Case Console search interfaces is located in the MasterSection.ascx file after the <ces:NoResultsAdvices> section.

<%-- Query summary (only if no results) --%>
<ces:IfNoResults runat="server">
  <ces:QuerySummary id="$Prefix$qsm" CssClass="CesQuerySummary" runat="server" />
  <ces:NoResultsAdvices CssClass="CesNoResultsAdvices" style="margin-top: 10px;" runat="server" />
  <ces:QuerySuggestions DisplaySampleResults="False" SortAscending="True" runat="server">
    <SuggestionTemplate>
      <div>
        <ces:QuerySuggestionLink runat="server" />
      </div>
    </SuggestionTemplate>
  </ces:QuerySuggestions>
</ces:IfNoResults>  

Mobile skin

The query suggestions are not available in the mobile skin templates.

Customizing Query Suggestions

As an administrator, you can customize a few aspects of the query suggestion feature by editing the skin templates.

To customize the query suggestions

  1. Using an administrator account, connect to your Coveo Front-End server.

  2. Navigate to the skin folder for the .NET search interface that you want to modify ([[.Net_Front-End_Path]\Web\Coveo\Skins\[search_interface]).

  3. Using a text editor:

    1. Open the ASCX file containing the query suggestion template (see Query Suggestions Skin Templates).

    2. Edit the file to perform one or more of the following possible customization.

      • Change the maximum number of returned results that triggers the query suggestions:

        In the <ces:QuerySuggestion> tag, add the FewResults="n" attribute to set the returned result count below or equal to n for which the query suggestion feature looks for alternate queries. The default value is 5 when not specified.

      • Display or not sample results

        In the <ces:QuerySuggestion> tag, add the DisplaySampleResults="true" attribute to make sample results appear. The default is false when not specified. The maximum number of sample result is also customizable.

        Example:

        Main part of the suggestion presenting the alternate query and indicating the number of returned results (always present)
        Two sample results for this query suggestion (optional)
      • Change the number of sample results to display per query suggestion

        In the <ces:QuerySuggestion> tag, add the NumberOfSampleResults="n" attribute to set the number of sample results to display. The default value is 2 when not specified.

      • Change the maximum number of query suggestions to try

        In the <ces:QuerySuggestion> tag, add the QueryLimit="n" attribute to set the maximum number of alternative queries tested by the query suggestion feature. The default value is 5 when not specified. Avoid a large number to prevent flooding the index.

      • Change how suggested queries are sorted

        When more than one query is suggested, the suggestions are sorted based on the number of results they return. In the <ces:QuerySuggestion> tag, add the SortAscending="True" attribute to sort starting with suggestions returning the smallest number of results. The default is False when not specified.

    3. Save the file.

  4. You can also customize what is displayed for each result. Using a text editor:

    1. Open the SuggestionSampleResult.ascx template file.

    2. Edit the file to modify, add, or remove elements.

      Example: To modify the <ces:ResultExcerpt ... /> element, refer to the API reference document to search and see available attributes (see ResultExcerpt Class Properties).

    3. Save the file.

  5. Using a browser, access the modified .NET search interface and perform queries to validate that the changes are as expected.

People who viewed this topic also viewed