Page1.xml
<pages xmlns="http://marklogic.com/docs">
<page>
<elementNode>data1</elementNode>
<textNode>text1</textNode>
</page>
<page>
<elementNode>data2</elementNode>
<textNode>text2</textNode>
</page>
<page>
<elementNode>data3</elementNode>
<textNode>text3</textNode>
</page>
<page>
<elementNode>data4</elementNode>
<textNode>text4</textNode>
</page>
</pages>
我在 elementNode 上创建了一个元素范围索引,然后执行了以下 XQuery:
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
declare namespace ts= "http://marklogic.com/docs";
import module namespace search ="http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
declare variable $options :=
<options xmlns="http://marklogic.com/appservices/search">
<searchable-expression xmlns:ex="http://marklogic.com/docs">//ex:page</searchable-expression>
<grammar>
<starter strength="30" apply="grouping" delimiter=")">(</starter>
<starter strength="40" apply="prefix" element="cts:not-query">NOT</starter>
<joiner strength="10" apply="infix" element="cts:or-query" tokenize="word">OR</joiner>
<joiner strength="20" apply="infix" element="cts:and-query" tokenize="word">AND</joiner>
<joiner strength="50" apply="constraint">:</joiner>
</grammar>
<constraint name="elementNode">
<range collation="http://marklogic.com/collation/" type="xs:string">
<facet-option>limit=1000</facet-option>
<element ns="http://marklogic.com/docs" name="elementNode"/>
<searchable-expression xmlns:ex="http://marklogic.com/clover/docs-xml">//ex:elementNode</searchable-expression>
</range>
</constraint>
</options>;
let $searchResult := search:search("elementNode:(*data*)", $options)
return $searchResult
在上述情况下,我没有得到任何结果,因为我在这里使用了通配符星号 [*]。有什么方法可以启用带有元素范围限制的通配符搜索?提前致谢。