【发布时间】:2015-12-10 10:50:29
【问题描述】:
我正在尝试使用 REST API 在 MarkLogic 中搜索一些内容并突出显示 XML 内容(如 google)中存在的搜索字符串。问题是当我在搜索字符串中包含“ME”时,它会突出显示“i”标签(html 斜体标签)以及内容中的“我”。我创建了一个包含一些元素的文档并在文档上运行单词查询。 例如 XML 内容:
<resources>
<title> some data from me</title>
<desc> more data <i> from </i> somewhere by me </desc>
</resources>
我创建了一个包含根节点“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>
网址:
localhost:9000/v1/search?q=some me&collection=Data&start=0&pageLength=10&options=Transformation&format=json
我正在使用 cts:highlight 进行突出显示,例如:
cts:highlight($final-result, $query, fn:concat('<span class="highlight">',$cts:text,'</span>')), $custom-config)
关于为什么此处突出显示 html 元素的任何想法? 提前致谢。
【问题讨论】:
标签: api rest search highlight marklogic