Interpreting item body as an HTML item

When indexing an item in your Coveo organization, that item must go through the mapping stage of the indexing pipeline process. At this stage, the item metadata is associated with fields in your index.

The mapping process is similar for the body of an item (that is, actual content) which is mapped to the body field whenever possible.

When analyzing your items through the Content Browser or from your search interface, you may find occurrences where an item excerpt and Quick view display HTML tags that come from the original repository document such as a web page, file, database record, or Salesforce object.

You can get rid of these HTML tags by applying a mapping rule that will cause the item body to be interpreted as an HTML document.

Search result with and without HTML tags
Warning

Using the following procedures modifies the default mapping behavior of the body field in a way that it becomes interpreted as an HTML document. Applying this kind of mapping to your source may cause the body field of some items to be filled with erroneous information which can lead to relevance issues.

Interpreting each item in a source as HTML

  1. In the Coveo Administration Console, access the Edit mappings panel, and then, select the Common tab.

  2. In the Edit mappings panel, click the Field dropdown menu, and then select the body field (that is, spobody in a SharePoint Online source).

  3. In the panel that appears:

    1. Under Rules, enclose the %[metadataName] placeholder with html/body tags as follows: <html><body>%[metadataName]</body></html>

    2. Click Save.

    Example

    To fill the [metadataName] placeholder with the description metadata, you create a mapping as follows:

    Field: body

    Apply to: All items (common)

    Rules: <html><body>%[description]</body></html>

  4. Back in the Edit mappings panel, click Save and rebuild source.

    Once the source rebuild process is complete, HTML tags originally appearing in the metadata used to populate the body field of your source items should be interpreted as such in item excerpts and Quick views. The items should also appear as HTML files in the Content Browser (platform-ca | platform-eu | platform-au) or in your search interface.

    Search result without HTML tags
Important

Coveo crawlers rely on multiple fields, depending on the repository, to create the body field of an item. By modifying the default mapping behavior of the body field, you may end up ignoring these fields, leading to an irrelevant or undesired item body.

For example, your item body that contains HTML tags is filled with the values of the Summary, Reporter, Assignee, Description, Comments, Creation date, and Modification date fields.

In order to remove the HTML tags from the item body, you create a mapping rule that maps the Summary and Description field values to the body field.

This action prevents the relevant data contained in the Reporter, Assignee, Comments, Creation date, and Modification date fields from being used to accurately build the item body.

Interpreting a subset of items in a source as HTML

  1. In the Coveo Administration Console, access the Edit mappings panel, and then, if you want to apply mapping to a subset of your source items, select the Specific tab.

  2. In the upper-right corner of the Edit mappings panel, click Add, and then select Item type.

  3. In the Add an Item Type panel, click the dropdown menu and then select or create the source item type (for example, text or article) for which you want the mapping to apply, and then click Add type.

  4. In the upper-right corner of the Edit mappings panel, click Add, and then select Mapping.

  5. In the panel that appears:

    1. Under Field, select the body field (that is, spobody in a SharePoint Online source).

      Tip

      The body field is named differently in each source, but most of the time it contains body in its display name.

    2. Under Apply to, select the Specific item types radio button, and then select the source item types for which you want the mapping to apply.

    3. Under Rules, enclose the %[metadataName] placeholder with html/body tags as follows: <html><body>%[metadataName]</body></html>

      Note

      In this procedure, the [metadataName] placeholder is filled with the description metadata.

    4. Click Apply mapping

  6. Back in the Edit mappings panel, click Save and rebuild source.

    Items matching the selected source item type (from step 3) should no longer display HTML tags. The items should also appear as HTML files in the Content Browser (platform-ca | platform-eu | platform-au) or in your search interface.

    Search result without HTML tags
Important

Coveo crawlers rely on multiple fields, depending on the repository, to create the body field of an item. By modifying the default mapping behavior of the body field, you may end up ignoring these fields, leading to an irrelevant or undesired item body.

For example, your item body that contains HTML tags is filled with the values of the Summary, Reporter, Assignee, Description, Comments, Creation date, and Modification date fields.

In order to remove the HTML tags from the item body, you create a mapping rule that maps the Summary and Description field values to the body field.

This action prevents the relevant data contained in the Reporter, Assignee, Comments, Creation date, and Modification date fields from being used to accurately build the item body.