Highlight Results

Knowledge Discovery is able to highlight text in three of its actions. It can highlight:

  • text supplied in the Text parameter of the Highlight action.

  • document content in the results of the Query action.

  • the HTML output of the View action.

The behavior of highlighting is broadly similar across these operations. Knowledge Discovery determines highlight matches using language rules (similar to query matches) and then surrounds these matches with a start tag and end tag of your choice.

For example, you might use HTML markup as start and end tags to display the output in a Web browser, with specified terms rendered to stand out visually.

Although highlighting functionality is used by a number of Knowledge Discovery components, the logic that it uses to find matches to highlight (and insert markup) is typically performed by the Content component.

Highlight Effectively

Highlighting uses the Knowledge Discovery language capabilities. For example, it uses stemming so that you do not have to specify various forms of a term.

For more precise highlighting, you can use Boolean and proximity operators, to take advantage of advanced query syntax.

In the Highlight action, if you supply HTML content to highlight, you must set XMLFormat to True to instruct Content to take into account the structure of markup languages (so that the result is still valid XML or HTML).

If highlighting is not working as expected, it might be helpful to test using the Highlight action directly with your Content component. In particular, check the language configuration, and specify the LanguageType parameter explicitly in the action.

Highlight with the View action

The View component View action uses the Content component Highlight action to highlight terms. Therefore, you can approach it in much the same way.

Because of this, the configuration of the Content might influence the behavior of the View component highlighting. View generally processes HTML, so it always uses the XMLFormat option in the action it sends to Content. It allows you to supply multiple start tag and end tag pairs so that you can highlight each term with a different visual style.

Examples

Here are examples of each highlighting action. For more details about parameters, refer to the Content Component Help and the View Component Help.

  • Wrap a single word in an arbitrary string in default start and end tags:

    action=highlight&text=Knowledge+Discovery+can+highlight+text&links=discovery

    Output:

    Copy
    <autn:content>
       Knowledge <font color=red>Discovery</font> can highlight text
    </autn:content>
  • Surround the matching text in a query action specifying StartTag and EndTag.

    NOTE: Note that matching is matched by match:

    action=query&text=match+highlight&highlight=terms&printfields=drecontent&starttag=*&endtag=*

    Output:

    Copy
    <DRECONTENT>
       This is sample text for *matching*. Hopefully you can see your *matches* *highlighted*.
    </DRECONTENT>
  • Decorate some search terms in a converted document with the View action:

    NOTE: The StartTag and EndTag parameters should be URL encoded, but are left plain in this example for clarity.

    action=view&reference=C:/viewing.pdf&links=viewing;service&noaci=True&multihighlight=True&starttag=<b>;<i>&endtag=</b>;</i>

    Output:

    Copy
    <html>
    ... <b>Viewing</b> <i>Service</i> ... 
    </html>