Loading TOC...


   $result as node(),
   $cts-query as schema-element(cts:query),
   [$options as element(search:transform-results)?]
) as element(search:snippet)


This function extracts matching text from the result node based on options, and returns the matches wrapped in a containing node, with highlights tagged.

result A node from which to pull matching snippets from.
cts-query A serialized and annotated cts:query, typically the result of a call to search:parse.
options Options to define the search grammar and control the search. See description for $options for the function search:search. Note that you cannot specify the apply attribute on the transform-results option with search:snippet; to use a different snippetting function, use search:search or search:resolve instead.

See Also


xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
    at "/MarkLogic/appservices/search/search.xqy";

 <html xmlns="http://www.w3.org/1999/xhtml">
        <title>Page Title</title>
       <div>Query terms in this div will be ignored for snippeting.</div>
       <p>Text surrounding query terms is highlighted and truncated
               according to configuration.</p>
      <transform-results apply="snippet"
              <element name="p" ns="http://www.w3.org/1999/xhtml"/>


<search:snippet xmlns:search="http://marklogic.com/appservices/search">
  <search:match path="/*:html/*:body/*:p[1]">
      Text surrounding query
      is highlighted and truncated according to configuration.


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