cts:score( [$node as node()] ) as xs:integer
Returns the score of a node, or of the context node if no node is provided.
Parameters | |
---|---|
node |
A node. Typically this is an item in the result sequence of a
cts:search
operation.
|
Score is computed according to the scoring method specified in the
cts:search
expression, if any.
If you run cts:score
on a constructed node, it always
returns 0; it is primarily intended to run on nodes that are retrieved
from the database (an item from a search result or an
item from the result of an XPath expression that searches through the
database).
(: run this on the Shakespeare content set :)
for $hit in cts:search(//SPEECH,
cts:word-query("with flowers"))[1 to 10]
return element hit {
attribute score { cts:score($hit) },
$hit
}
xdmp:document-insert("/test.xml", <a>my test</a>);
for $x in cts:search(doc("/test.xml"),"my test")
return cts:score($x) => 11
for $a in cts:search(collection(),"my test")
where $a[cts:score() gt 10]
return xdmp:node-uri($a) => /test.xml
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.