Skip to main content
The Highlight stage allows you to highlight key parts of fields by generating snippets and appending match tags to the highlighted terms. The highlight match tags can then be styled in your web search application. Highlight stage highlights
To see highlighting in the Query Workbench, turn it on by setting Format Results > Display highlighting? to true:Display highlighting option
How does this differ from other highlight methods?
  • Highlight Query Pipeline Stage. Introduced in Fusion 5.2.0, the Query Highlight pipeline stage allows you to configure standard options for highlighting using Solr’s Unified highlighter instead of adding Solr request parameters. For instructions, see Configure the Highlight Query Pipeline Stage.
  • Additional Query Parameters stage. For Fusion 5.2.0 and later, the same method used in Fusion 5.1.x can be used. Configure highlighting with the Additional Query Parameters stage. For instructions, see Configure Highlighting in the Query Workbench.
The Highlight stage allows you to highlight key parts of fields by generating snippets and appending match tags to the highlighted terms. The highlight match tags can then be styled in your web search application.To configure the Highlight stage:
  1. Navigate to Querying > Query Workbench.
  2. Click Add a Stage and choose Highlight from the list.
  3. Click the + Highlight Fields button, and input the field name(s) to configure highlighting for. Repeat to enter multiple fields, if desired.
  4. Assign a Snippet count value. With a value of 3, Fusion will attempt to generate 3 snippets containing highlighted terms.
  5. Assign a Snippet length value. With a value of 100, Fusion will attempt to create snippets that are around 100 characters in length.
  6. Assign Match tag values. These values are used to wrap the highlighted terms. By default, <em> and </em> are used. You can use other values for the match tags, such as <span style="background-color:powderblue;"> and </span>, but the Fusion UI will not reflect your custom styles.
  7. (optional) Set Default highlight to true if you want to generate snippets even when no highlights are found. The Snippet count and Snippet length values are still in effect.
  8. Click the Apply button to preview highlighting.
    To see highlighting in the Query Workbench, turn it on by setting Format Results > Display highlighting? to true: Display highlighting option
  9. When you are satisfied with your changes, click the Save button to save the pipeline.
Search results can be displayed with the search terms highlighted, by adding these Solr query parameters to the Additional Query Parameters stage of the query pipeline:
  • hl=true
  • hl.fl=*
By default, the Query Workbench ignores these parameters when rendering search results. To view highlighted search results in the preview panel of the Query Workbench, you must configure the parameters above and enable the Display highlighting option.How to enable highlighting in the preview panel
  1. Add the Additional Query Parameters stage to your query pipeline, or select it if it is already there.
  2. Under Parameters and Values, add the following query parameters and values: Highlighting params
  3. Click Apply. At this point, no highlighting appears in the preview panel.
  4. At the bottom of the window, click Format Results.
  5. Select Display highlighting. Highlighting option
  6. Click Save. Now our search results include highlighted search terms: Highlighted search terms

Query pipeline stage condition examples

Stages can be triggered conditionally when a script in the Condition field evaluates to true. Some examples are shown below. Run this stage only for mobile clients:
params.deviceType === "mobile"
Run this stage when debugging is enabled:
params.debug === "true"
Run this stage when the query includes a specific term:
params.q && params.q.includes("sale")
Run this stage when multiple conditions are met:
request.hasParam("fusion-user-name") && request.getFirstParam("fusion-user-name").equals("SuperUser");
!request.hasParam("isFusionPluginQuery")
The first condition checks that the request parameter “fusion-user-name” is present and has the value “SuperUser”. The second condition checks that the request parameter “isFusionPluginQuery” is not present.

Parameters

Highlight Fields

Specifies the fields to use for highlighting. Highlighting should be used for text fields only. These fields are typically identified by the _t suffix, for example: longDescription_t.

Snippet count

Specifies the number of snippets to generate for each configured field. When Snippet count is assigned a value of 3, for example, the following is returned:
"highlighting": {
    "link:/fusion/5.2/concepts/signals-and-aggregations/signals/": {
        "body_t": [
            "Click <em>signals</em> are the most common type of <em>signals</em> as this is the most common action a user takes with an item. ", // 1
            "The <em>signals</em> collection is created automatically when <em>signals</em> are enabled for the primary collection. ", // 2
            "App Insights mainly uses raw <em>signals</em>, but also uses some aggregated <em>signals</em>. " // 3
        ]
    }
}

Snippet length

Controls the length of snippets. The Snippet length value is a character count. For example, setting Snippet count to 3 and Snippet length to 5 will attempt to generate 3 snippets that are at least 5 characters long:
"highlighting": {
    "link:/fusion/4.1/concepts/signals-and-aggregations/signals/": {
        "body_t": ["Click <em>signals</em> are the most common type of <em>signals</em> as this is the most common action a user takes with an item. ", // 1
        "The <em>signals</em> collection is created automatically when <em>signals</em> are enabled for the primary collection. ",  // 2
        "App Insights mainly uses raw <em>signals</em>, but also uses some aggregated <em>signals</em>. " // 3
        ]
    }
}
In the example above, 3 snippets were generated, each snippet was at least 5 characters long, and snippets returned as a complete sentence. Setting the Snippet length to a higher value, such as 500, may result in a single long snippet despite a Snippet count value of 3:
  "highlighting": {
      "link:/fusion/5.2/concepts/signals-and-aggregations/signals/": {
          "body_t": ["<em>Signals</em> are indexed in a secondary collection which is linked to the primary collection by the naming convention <primarycollectionname>_signals. So, if your main collection is named products, the associated <em>signals</em> collection is named products_signals. The <em>signals</em> collection is created automatically when <em>signals</em> are enabled for the primary collection. <em>Signals</em> are enabled by default whenever a new collection is created. <em>Signals</em> are indexed just like ordinary documents. The <em>signals</em> collection can be searched like any other collection, for example by using the Query Workbench with the <em>signals</em> collection selected. App Insights provides visualizations and reports with which to analyze your <em>signals</em>. App Insights mainly uses raw <em>signals</em>, but also uses some aggregated <em>signals</em>. Currently only the signal types Request, Response and Click are supported within the App Insights dashboards. See the descriptions of <em>signals</em> types and structure for more information. "]
      }
  }

Match tags

Specifies the tags to use for identifying highlighted portions of the snippet. By default <em> and </em> are used. Match tags are appended to the highlight response field: JSON
  "highlighting" : {
    "8483697" : {
      "longDescription_t" : [ "Use these <em>powerful</em> headphones to stay focused on the music and help tune out background noise." ]
    },
    "2132048" : {
      "longDescription_t" : [ "Enjoy the beats and rhythms of your favorite music with these stylish over-the-ear headphones that feature 40mm drivers for clear and <em>powerful</em> sound. " ]
    }
  }
You can use other values for the match tags, such as <span style="background-color:powderblue;"> and </span>, but the Fusion UI will not reflect your custom styles.

Default highlight

If no highlighting match is found, the results are returned without highlighting. This is easiest to see in the JSON. In the examples below, longDescription_t is as the Highlight Fields value.
Default highlight false

UI

JSON
"highlighting" : {
    "8483697" : {
      "longDescription_t" : [ ]
    },
    "2132048" : {
      "longDescription_t" : [ ]
    }
  }
In the examples above, no highlight match is found for the documents. Turn on Default highlight to force the stage to return the leading part of the field instead. Use this option to avoid returning large fields if you need to display something even when there is no highlight match.
Default highlight true

UI

JSON
  "highlighting" : {
    "8483697" : {
      "longDescription_t" : [ "Use these powerful headphones to stay focused on the music and help tune out background noise." ]
    },
    "2132048" : {
      "longDescription_t" : [ "Enjoy the beats and rhythms of your favorite music with these stylish over-the-ear headphones that feature 40mm drivers for clear and powerful sound. " ]
    }
  }

Configuration

When entering configuration values in the UI, use unescaped characters, such as \t for the tab character. When entering configuration values in the API, use escaped characters, such as \\t for the tab character.
I