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.

To remove these HTML tags, apply a mapping rule that will cause the item body to be interpreted as an HTML document rather than plain text.

Search result with and without HTML tags

Before following either procedure, confirm that your source type exposes the item’s HTML as metadata. In some cases, the source mapping populates the body field by concatenating several metadata values.

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. On the Sources (platform-ca | platform-eu | platform-au) page, click your source, and then click Mappings in the Action bar.

  2. On the Common tab of the Edit mappings subpage, locate the body field. For example, that would be the spobody field in a SharePoint Online source.

  3. Click that field, and then click Edit mapping in the Action bar.

  4. In the panel that appears:

    1. Under Rules, enclose the %[<METADATA_NAME>] placeholder in <html> and <body> tags. For example, if the metadata used in the mapping rule is description, the updated rule would be: <html><body>%[description]</body></html>. See Mapping rule syntax reference to learn how rules are applied.

    2. Click Apply mapping.

  5. Back in the Edit mappings subpage, 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 quickviews. 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. On the Sources (platform-ca | platform-eu | platform-au) page, click your source, and then click Mappings in the Action bar.

  2. On the Specific tab of the Edit mappings subpage, click Add item type at the top right.

  3. In the Add an item type modal:

    1. Under Item type name, enter the name of the item type. See Find the source item type values to determine which item type names to use.

    2. Under Field, click the body field. For example, that would be the spobody field in a SharePoint Online source.

    3. Under Rules, enclose the %[<METADATA_NAME>] placeholder in <html> and <body> tags. For example, if the metadata used in the mapping rule is description, the updated rule would be: <html><body>%[description]</body></html>. See Mapping rule syntax reference to learn how rules are applied.

    4. Click Add item type and mapping.

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

    Items matching the selected item type 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.