我正在尝试使用REST API搜索某些内容并突出显示MarkLogic中XML内容(如google)中的搜索字符串.问题是当我在搜索字符串中包含"ME"时,它会在内容中突出显示"i"标记(html斜体标记)和"Me".我创建了一个包含一些元素的文档,并在文档上运行了单词查询.例如XML内容:
<resources>
<title> some data from me</title>
<desc> more data <i> from </i> somewhere by me </desc>
</resources>
Run Code Online (Sandbox Code Playgroud)
我创建了一个文档,其中包含根节点"resources"和子元素"title"和"desc",并使用word-query搜索文档中的搜索字符串.
现在,当我搜索"some me"时,它会检索内容
<resources>
<title> <<span class="highlight">some</span> data from <<span class="highlight">me</span>
</title>
<desc> more data <<span class="highlight">i</span>> from <<span class="highlight">i</span>> somewhere by <span class="highlight">me</span> </desc>
</resources>
Run Code Online (Sandbox Code Playgroud)
网址:
localhost:9000/v1/search?q=some me&collection=Data&start=0&pageLength=10&options=Transformation&format=json
Run Code Online (Sandbox Code Playgroud)
我正在使用cts:突出显示突出显示,有些事情如下:
cts:highlight($final-result, $query, fn:concat('<span class="highlight">',$cts:text,'</span>')), $custom-config)
Run Code Online (Sandbox Code Playgroud)
关于为什么html元素在这里被突出显示的任何想法?提前致谢.