<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/cts.confidence.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>cts.confidence</api:function-name><api:suggest>cts.confidence</api:suggest><api:suggest>cts</api:suggest><api:suggest>confidence</api:suggest><api:function-link mode="xquery" fullname="cts:confidence">/apidoc/8.0/cts:confidence.xml</api:function-link><api:function mode="javascript" name="confidence" type="builtin" lib="cts" category="SearchBuiltins" subcategory="Search" hidden="false" bucket="MarkLogic Built-In Functions" prefix="cts" namespace="http://marklogic.com/cts" fullname="cts.confidence"><api:summary>
  Returns the confidence of a node,
  or of the context node if no node is provided.
</api:summary><api:params><api:param name="node" type="node()" optional="true"><api:param-description>
    A node. Typically this is an item in the result sequence of a
    <code xmlns="http://www.w3.org/1999/xhtml">cts:search</code> operation.
  </api:param-description><api:param-name>node</api:param-name><api:param-type>Node</api:param-type></api:param></api:params><api:return>Number</api:return><api:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">Confidence is similar to score, except that it is bounded.
   It is similar to fitness, except that it is influenced by term IDFs.
   It is an <code>xs:float</code> in the range of 0.0 to 1.0.
   It does not include quality.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">When using with any of the scoring methods, the confidence is
   calculated by first bounding the score in the range of 0.0 to 1.0,
   then taking the square root of that number.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var res = new Array();
var count = 0;
var s = cts.search("dog");
for (var item of s) {
 count++;
  if (count &gt; 3) { break;}
 res.push(cts.confidence(item));
 res.push(xdmp.nodeUri(item));
}
res;

// returns an array of the confidence numbers and the URI for the
// first 3 items returned by the search
</pre></api:example></api:function></api:function-page>