如何搜索编码的unicode字符?
e.g。这可以正常工作
search:search('ģ')
但这不是:
(: $search-for received encoded with & :)
xdmp:log($search-for), (: prints "#x0123;" :)
search:search($search-for)
输出包含:
<search:qtext>&#x0123;</search:qtext>
检测字符串是否包含&amp;的最佳方式是什么?转换它?
答案 0 :(得分:1)
我认为某些浏览器或其他工具会欺骗你。当我在QConsole(MarkLogic 8.0-5.2)中运行它时:
xdmp:document-insert('/unicode.xml', <p>hello ģ world</p>)
;
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
let $search-for := "ģ"
return
search:search($search-for)
我明白了:
<search:response snippet-format="snippet" total="1" start="1" page-length="10" xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="/unicode.xml" path="fn:doc("/unicode.xml")" score="36864" confidence="0.5609438" fitness="0.6934683">
<search:snippet>
<search:match path="fn:doc("/unicode.xml")/p">hello <search:highlight>ģ</search:highlight> world</search:match>
</search:snippet>
</search:result>
<search:qtext>ģ</search:qtext>
<search:metrics>
<search:query-resolution-time>PT0.003526S</search:query-resolution-time>
<search:snippet-resolution-time>PT0.001206S</search:snippet-resolution-time>
<search:total-time>PT0.005372S</search:total-time>
</search:metrics>
</search:response>
E.g。 unicode字符不会被转义。
HTH!