THIS IS ARCHIVED DOCUMENTATION

Query Suggestions Using the Coveo for Sitecore Legacy Search UI Framework

Coveo for Sitecore 4.1 (November 2018)

The Coveo Machine Learning (Coveo ML) Query Suggestions (QS) 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 Usage Analytics (Coveo UA) 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 Coveo ML advanced QS

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 Get Started With Coveo Machine Learning).

  4. Click OK.

  5. Save and publish the page.

  6. In the Coveo Cloud Administration Console, create a Coveo ML QS model).

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’s 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 facetable).

  • 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.