Coveo for Sitecore v5 is now available!

Query Suggestions Using the Coveo for Sitecore Legacy Search UI Framework

Coveo for Sitecore 4.1 - November 2018

The query suggestions feature, or type-ahead, proposes a query to the user based on the first few letters entered in the search box. You can provide suggestions using machine learning or a specific field.

Coveo Machine Learning Based Suggestions

Pro and Enterprise Cloud only

Prerequisites:

  • Coveo Cloud Usage Analytics needs to be enabled on your page (see Coveo Usage Analytics).
  • The Omnibox must be enabled on your page (see Search Component Properties).
  • You need to use the Coveo Search Resources component (Web Forms) or the Coveo Search View Resources component (MVC), not the Coveo Search Box Resources component (Web Forms) or the Coveo Search Box View Resources component (MVC).

To activate the Coveo ML advanced query suggestions:

 Open your Search Page (or the page containing your Omnibox) in the Experience Editor.

 Click the search box, and then in the Coveo Search component, click the Properties icon.

In the Properties dialog:

  1. Scroll down to Searchbox Suggestions.

  2. Select Query suggestions.

  3. Select Coveo ML Advanced Query Suggestions (see Getting Started with Coveo Machine Learning).

  4. Click OK.

  5. Save and publish the page.

  6. In the Cloud administration console, configure a query suggestion Coveo ML model (see Managing Coveo Machine Learning Query Suggestions Models in a Query Pipeline).

Analytics Based Suggestions

Since the December 2017 release of Coveo for Sitecore 4.0, the Analytics Top Query Suggestions option is disabled for all versions.

Field Based Suggestions

Using fields is an easy way to provide suggestions, but it is not as efficient or relevant as the analytics based suggestions described above.

Main article: FieldSuggestions Component

This component is used to provide query suggestions based on a particular facet field. It can be added in both the Search Interface and the Search Box.

Search Interface (Coveo Search/Coveo Search View)

Prerequisites:

Instructions:

  1.  Locate the element with the CoveoSearchInterface class in the ascx file (Web Forms) or the cshtml file (MVC) of your Coveo Search component copy.

  2. Add the following element anywhere between the opening <div> tag and the closing </div> tag of that element:

    1. Web Forms

      <span class="CoveoFieldSuggestions" data-field='<%= Model.ToCoveoFieldName("MySitecoreField") %>'></span>
      
    2. MVC

      <span class="CoveoFieldSuggestions" data-field='@(Model.ToCoveoFieldName("MySitecoreField"))'></span>
      
  3. Replace MySitecoreField with the desired Sitecore field name.
  4. Save the file.

Standalone Search Box (Coveo Search Box/Coveo Search Box View)

Prerequisites:

  • A copy of the default Coveo Search Box component (see Duplicating the Coveo Search Component).
  • The field used for suggestions needs to be a facet field (see Making a Sitecore field facettable).
  • You need to use the Coveo Search Resources component (Web Forms) or the Coveo Search View Resources component (MVC), not the Coveo Search Box Resources component (Web Forms) or the Coveo Search Box View Resources component (MVC).

Instructions:

  1. Locate the element with the CoveoSearchbox class in the ascx file (Web Forms) or the cshtml file (MVC) of your Coveo Search Box component copy.

  2. Add the following element anywhere between the opening <div> tag and the closing </div> tag of that element:

    1. Web Forms

      <span class="CoveoFieldSuggestions" data-header-title="MySitecoreFieldTitle" data-field='<%= Model.ToCoveoFieldName("MySitecoreField") %>'></span>
      
    2. MVC

      <span class="CoveoFieldSuggestions" data-header-title="MySitecoreFieldTitle" data-field='@(Model.ToCoveoFieldName("MySitecoreField"))'></span>
      
  3. Replace MySitecoreFieldTitle with the desired title.
  4. Replace MySitecoreField with the desired Sitecore field name.
  5. Save the file.