Get Smart Snippets for Sitecore Content

The Coveo Machine Learning (Coveo ML) Smart Snippets feature targets index items whose language field value is English. By default, Sitecore English version items are indexed with en as the language field value. To be scanned as potential smart snippet answers to user queries, you must add an indexing pipeline extension to your Sitecore source to replace en with English as the language field value on Sitecore items. This article provides instructions on how to do this.

Create the Extension

  1. On the Extensions (platform-eu | platform-au) page of the Coveo Administration Console, click Add extension.

  2. In the Add an Extension panel, give your extension a name and a description. No need to select any additional item data options.

    Extension to set language field value to English
  3. In the Extension script field, paste the following code:

    language = document.get_meta_data_value('language')
    if language[0] == 'en':
      document.add_meta_data({'language': 'English'})
  4. Click Add extension.

Associate the Extension to Your Source

To link your extension to a source, you can proceed as follows:

  1. On the Sources (platform-eu | platform-au) page of the Coveo Administration Console, click the Sitecore source you want to apply your extension to, and then click More > Manage extensions in the Action bar.

  2. In the Edit Source Extensions panel, in the Common tab, click Add > Extension.

  3. In the Apply an Extension on Source Items panel, select your extension in the drop-down.

  4. Under Stage, select Post-Conversion.

  5. Under Action on Error, select Skip Extension.

  6. In the Conditions to apply field, type %[haslayout] == 1. This condition ensures the extension is only applied to Sitecore HTML content items.

    Applying IPE to source items
  7. Click Apply extension.

  8. Back in the Edit Source Extensions panel, click Save.

  9. Rebuild that source from your Sitecore instance, so that the extension gets executed on your items.

Note

For general guidance on adding indexing pipeline extensions, see Manage Indexing Pipeline Extensions.

What's next for me?