Server-side JavaScript

Mark-up

cts.highlight is a powerful function that allows you to traverse a document and mark-up matches based on a query. The query can be anything from a simple word query to a sophisticated Boolean query with geospatial, range, and word terms. Highlighting over XML, you can build snippets and highlights, for example, to report as search results.

Highlighting also supports JSON nodes. While JSON doesn't lend itself to inline markup, as XML does, cts.highlight() does the hard work of splitting nodes and interleaving highlights.

The resulting matches are interspersed within what used to be a single string property.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.