我正在使用以下查询,该查询cts:search
在生产中运行时需要花费大量时间
xquery version "1.0-ml";
(: let $limit := () use this instead to display all values :)
for $uri in cts:uri-match("/tag-cloud/*")
let $values :=""
let $region := fn:substring-before(fn:substring-after($uri, "/tag-cloud/"), ".xml")
let $doc := concat("/tag-cloud/",$region,".xml")
let $distinct-search-text := cts:search(doc($doc)/All-searchtext/searchtext,
cts:element-attribute-range-query(xs:QName("searchtext"), xs:QName("date"),
">=",
(fn:current-date() - xs:dayTimeDuration("P2D"))
)
)
let $result-xml := for $each-search-text in fn:distinct-values($distinct-search-text/text())
let $count := count($distinct-search-text[text() eq $each-search-text])
order by $count descending
return
fn:concat($region,"	", $each-search-text, "	",$count)
return
for $eachtag in (($result-xml)[1 to 15])
return ($eachtag)
谁能帮我用cts:element-values
函数重写上面的查询,因为我只需要频率值。
我尝试了以下查询,但过滤无法正常工作。任何帮助都非常感谢
xquery version "1.0-ml";
let $limit := 15
(: let $limit := () use this instead to display all values :)
for $uri in cts:uri-match("/tag-cloud/*")
let $region := fn:substring-before(fn:substring-after($uri, "/tag-cloud/"), ".xml")
let $values :=
cts:element-values(
xs:QName("searchtext"),
"",
(
"collation=http://marklogic.com/collation/codepoint",
"item-frequency",
"frequency-order",
"descending",
if (fn:exists($limit)) then fn:concat("limit=", $limit) else ()
),
cts:and-query((
cts:element-attribute-range-query(xs:QName("searchtext"), xs:QName("date"),
">=",
(fn:current-date() - xs:dayTimeDuration("P2D"))
),
cts:document-query($uri)))
)
for $value in $values
return
fn:concat($region, "	", $value, "	", cts:frequency($value))
谢谢