我有这段代码
declare variable $a as xs:string := "case-insensitive punctuation-insensitive
unwildcarded";
declare variable $b as xs:string* := tokenize($a, ' ');
let $d as cts:query := cts:field-word-query("FULL-CASE-NAME", "complaints",
$b, 30)
return <q>{$d}</q>
产生此结果
<q>
<cts:field-word-query weight="30" xmlns:cts="http://marklogic.com/cts">
<cts:field>FULL-CASE-NAME</cts:field>
<cts:text xml:lang="en">complaints</cts:text>
<cts:option>case-insensitive</cts:option>
<cts:option>punctuation-insensitive</cts:option>
<cts:option>unwildcarded</cts:option>
</cts:field-word-query>
</q>
但是我想生产的是这个
<q>
<cts:field-word-query weight="30" xmlns:cts="http://marklogic.com/cts">
<cts:field weight="10">FULL-CASE-NAME</cts:field>
<cts:text xml:lang="en">complaints</cts:text>
<cts:option>case-insensitive</cts:option>
<cts:option>punctuation-insensitive</cts:option>
<cts:option>unwildcarded</cts:option>
</cts:field-word-query>
</q>
这一行的区别在于增加了权重作为属性
<cts:field weight="10">FULL-CASE-NAME</cts:field>
答案 0 :(得分:2)
cts:field
仅保留字段名称。权重(初始代码中为30)已经存在,并作为属性附加到所属的cts:field-word-query
上。
HTH!