1
Page1.xmlMarklogic:Wilcard上元範圍索引搜索與搜索:搜索
<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
在以上情況我沒有得到任何結果,因爲我在這裏使用了通配符星號[*]。有什麼方法可以通過元素範圍約束來啓用通配符搜索?提前致謝。